Skip to contentSkip to conversation

net/mlx4_core: fix handling return value of mlx4_slave_convert_port

PATCH In review Andrzej Hajda 8 participants 19 messages Dec 14, 2015 – Dec 31, 2015

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/mlx4_core: fix handling return value of mlx4_slave_convert_port

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +3 -2
index da7f578..b46dbe2 100644
@@ -4331,9 +4331,10 @@ int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
 		return -EOPNOTSUPP;
 
 	ctrl = (struct mlx4_net_trans_rule_hw_ctrl *)inbox->buf;
-	ctrl->port = mlx4_slave_convert_port(dev, slave, ctrl->port);
-	if (ctrl->port <= 0)
+	err = mlx4_slave_convert_port(dev, slave, ctrl->port);
+	if (err <= 0)
 		return -EINVAL;
+	ctrl->port = err;
 	qpn = be32_to_cpu(ctrl->qpn) & 0xffffff;
 	err = get_res(dev, slave, qpn, RES_QP, &rqp);
 	if (err) {
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 clk: sunxi: fix handling return value of of_property_match_string

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/clk/sunxi/clk-sun8i-bus-gates.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clk/sunxi/clk-sun8i-bus-gates.c +4 -4
index 7ab60c5..ecadd97 100644
@@ -47,12 +47,12 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node)
 		return;
 
 	for (i = 0; i < ARRAY_SIZE(names); i++) {
-		index = of_property_match_string(node, "clock-names",
-						 names[i]);
-		if (index < 0)
+		int idx = of_property_match_string(node, "clock-names",
+						   names[i]);
+		if (idx < 0)
 			return;
 
-		parents[i] = of_clk_get_parent_name(node, index);
+		parents[i] = of_clk_get_parent_name(node, idx);
 	}
 
 	clk_data = kmalloc(sizeof(struct clk_onecell_data), GFP_KERNEL);
Signature · 1 line
1.9.1
#2 lore raw

Re: [PATCH] clk: sunxi: fix handling return value of of_property_match_string

Hi,

Quoted 9 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Applied, thanks!
Maxime

Signature · 10 lines
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151214/439a066f/attachment.sig>
#3 lore raw

PATCH 1/1 ath9k_htc: fix handling return value of ath9k_hw_calibrate

In reply to Andrzej Hajda

The function can return negative values in case of error. Its result should be then tested for such case.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/net/wireless/ath/ath9k/htc_drv_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_drv_main.c +1 -1
index a680a97..fe1fd1a 100644
@@ -834,7 +834,7 @@ void ath9k_htc_ani_work(struct work_struct *work)
 		if (longcal || shortcal)
 			common->ani.caldone =
 				ath9k_hw_calibrate(ah, ah->curchan,
-						   ah->rxchainmask, longcal);
+						ah->rxchainmask, longcal) > 0;
 
 		ath9k_htc_ps_restore(priv);
 	}
Signature · 1 line
1.9.1
Applied
#4 lore raw

Re: [PATCH] ath9k_htc: fix handling return value of ath9k_hw_calibrate

Quoted 9 lines · Andrzej Hajda

The function can return negative values in case of error. Its result should be then tested for such case.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Applied to ath.git, thanks.

Signature · 1 line
Kalle Valo
#5 lore raw

PATCH 1/1 be2iscsi: fix handling return value of mgmt_open_connection

In reply to Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/scsi/be2iscsi/be_iscsi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/be2iscsi/be_iscsi.c +2 -2
index b7087ba..ce9f192 100644
@@ -1106,8 +1106,8 @@ static int beiscsi_open_conn(struct iscsi_endpoint *ep,
 	struct beiscsi_hba *phba = beiscsi_ep->phba;
 	struct tcp_connect_and_offload_out *ptcpcnct_out;
 	struct be_dma_mem nonemb_cmd;
-	unsigned int tag, req_memsize;
-	int ret = -ENOMEM;
+	unsigned int req_memsize;
+	int tag, ret = -ENOMEM;
 
 	beiscsi_log(phba, KERN_INFO, BEISCSI_LOG_CONFIG,
 		    "BS_%d : In beiscsi_open_conn\n");
Signature · 1 line
1.9.1
#6 lore raw

PATCH 1/1 doc: mei: fix handling return value of mei_recv_msg

In reply to Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 Documentation/misc-devices/mei/mei-amt-version.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/misc-devices/mei/mei-amt-version.c +1 -1
index 57d0d87..33e67bd 100644
@@ -370,7 +370,7 @@ static uint32_t amt_host_if_call(struct amt_host_if *acmd,
 			unsigned int expected_sz)
 {
 	uint32_t in_buf_sz;
-	uint32_t out_buf_sz;
+	ssize_t out_buf_sz;
 	ssize_t written;
 	uint32_t status;
 	struct amt_host_if_resp_header *msg_hdr;
Signature · 1 line
1.9.1
#7 lore raw

RE: [PATCH] doc: mei: fix handling return value of mei_recv_msg

Quoted 19 lines

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 Documentation/misc-devices/mei/mei-amt-version.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Documentation/misc-devices/mei/mei-amt-version.c +0 -0
index 57d0d87..33e67bd 100644

Documentation/misc-devices/mei/mei-amt-version.c static uint32_t amt_host_if_call(struct amt_host_if · line 373

Quoted 4 lines
Documentation/misc-devices/mei/mei-amt-version.c +0 -0
@@ -370,7 +370,7 @@ static uint32_t amt_host_if_call(struct amt_host_if
 *acmd,
 			unsigned int expected_sz)
 {
 	uint32_t in_buf_sz;

If are you at that then it will be desired to change the type to ssize_t also for in_buf_sz as mei_recv_msg takes ssize_t argument.

Quoted 5 lines
Documentation/misc-devices/mei/mei-amt-version.c +1 -1
-	uint32_t out_buf_sz;
+	ssize_t out_buf_sz;
 	ssize_t written;
 	uint32_t status;

struct amt_host_if_resp_header *msg_hdr;

Thanks
Tomas

#8 lore raw

PATCH 1/1 extcon: max77843: fix handling return value of regmap_irq_get_virq

In reply to Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max77843.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max77843.c +1 -1
index 9f9ea33..74dfb7f 100644
@@ -811,7 +811,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 
 	for (i = 0; i < ARRAY_SIZE(max77843_muic_irqs); i++) {
 		struct max77843_muic_irq *muic_irq = &max77843_muic_irqs[i];
-		unsigned int virq = 0;
+		int virq = 0;
 
 		virq = regmap_irq_get_virq(max77843->irq_data_muic,
 				muic_irq->irq);
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#9 lore raw

Re: [PATCH] extcon: max77843: fix handling return value of regmap_irq_get_virq

2015-12-14 19:06 GMT+09:00 Andrzej Hajda <[email protected]>:

Quoted 6 lines

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

Quoted 7 lines

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max77843.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Best regards,
Krzysztof

maintainer
#10 lore raw

Re: [PATCH] extcon: max77843: fix handling return value of regmap_irq_get_virq

In reply to Andrzej Hajda
Quoted 19 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max77843.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max77843.c +0 -0
index 9f9ea33..74dfb7f 100644

drivers/extcon/extcon-max77843.c static int max77843_muic_probe(struct platform_device *pdev) · line 817

Quoted 8 lines
drivers/extcon/extcon-max77843.c +1 -1
@@ -811,7 +811,7 @@ static int max77843_muic_probe(struct platform_device *pdev)
 
 	for (i = 0; i < ARRAY_SIZE(max77843_muic_irqs); i++) {
 		struct max77843_muic_irq *muic_irq = &max77843_muic_irqs[i];
-		unsigned int virq = 0;
+		int virq = 0;
 
 		virq = regmap_irq_get_virq(max77843->irq_data_muic,
 				muic_irq->irq);

Applied it.

Thanks,
Chanwoo Choi

#11 lore raw

PATCH 1/1 extcon: max14577: fix handling return value of regmap_irq_get_virq

In reply to Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max14577.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max14577.c +1 -1
index 601dbd9..b30ab97 100644
@@ -692,7 +692,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
 	/* Support irq domain for max14577 MUIC device */
 	for (i = 0; i < info->muic_irqs_num; i++) {
 		struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
-		unsigned int virq = 0;
+		int virq = 0;
 
 		virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);
 		if (virq <= 0)
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#12 lore raw

Re: [PATCH] extcon: max14577: fix handling return value of regmap_irq_get_virq

2015-12-14 19:06 GMT+09:00 Andrzej Hajda <[email protected]>:

Quoted 6 lines

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

Quoted 7 lines

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max14577.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Do you plan to fix also max77693?

Best regards,
Krzysztof

#13 lore raw

PATCH 1/1 extcon: max77693: fix handling return value of regmap_irq_get_virq

The function can return negative values, so its result should be assigned to signed variable.

---
 drivers/extcon/extcon-max77693.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon-max77693.c +2 -2
index 44c499e..fdf8f5d 100644
@@ -1127,11 +1127,11 @@ static int max77693_muic_probe(struct platform_device *pdev)
 	/* Support irq domain for MAX77693 MUIC device */
 	for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
 		struct max77693_muic_irq *muic_irq = &muic_irqs[i];
-		unsigned int virq = 0;
+		int virq;
 
 		virq = regmap_irq_get_virq(max77693->irq_data_muic,
 					muic_irq->irq);
-		if (!virq)
+		if (virq <= 0)
 			return -EINVAL;
 		muic_irq->virq = virq;
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#14 lore raw

Re: [PATCH] extcon: max77693: fix handling return value of regmap_irq_get_virq

Quoted 8 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

---
 drivers/extcon/extcon-max77693.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Best regards,
Krzysztof

maintainer
#15 lore raw

Re: [PATCH] extcon: max77693: fix handling return value of regmap_irq_get_virq

In reply to Andrzej Hajda
Quoted 18 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

---
 drivers/extcon/extcon-max77693.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/extcon/extcon-max77693.c +0 -0
index 44c499e..fdf8f5d 100644
@@ -1127,11 +1127,11 @@ static int max77693_muic_probe(struct platform_device *pdev)
 	/* Support irq domain for MAX77693 MUIC device */
 	for (i = 0; i < ARRAY_SIZE(muic_irqs); i++) {
 		struct max77693_muic_irq *muic_irq = &muic_irqs[i];

drivers/extcon/extcon-max77693.c static int max77693_muic_probe(struct platform_device *pdev) · line 1137

Quoted 10 lines
drivers/extcon/extcon-max77693.c +2 -2
-		unsigned int virq = 0;
+		int virq;
 
 		virq = regmap_irq_get_virq(max77693->irq_data_muic,
 					muic_irq->irq);
-		if (!virq)
+		if (virq <= 0)
 			return -EINVAL;
 		muic_irq->virq = virq;
 

Applied it.

Thanks,
Chanwoo Choi

maintainer
#16 lore raw

Re: [PATCH] extcon: max14577: fix handling return value of regmap_irq_get_virq

In reply to Andrzej Hajda
Quoted 19 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

---
 drivers/extcon/extcon-max14577.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/extcon/extcon-max14577.c +0 -0
index 601dbd9..b30ab97 100644

drivers/extcon/extcon-max14577.c static int max14577_muic_probe(struct platform_device *pdev) · line 698

Quoted 8 lines
drivers/extcon/extcon-max14577.c +1 -1
@@ -692,7 +692,7 @@ static int max14577_muic_probe(struct platform_device *pdev)
 	/* Support irq domain for max14577 MUIC device */
 	for (i = 0; i < info->muic_irqs_num; i++) {
 		struct max14577_muic_irq *muic_irq = &info->muic_irqs[i];
-		unsigned int virq = 0;
+		int virq = 0;
 
 		virq = regmap_irq_get_virq(max14577->irq_data, muic_irq->irq);
 		if (virq <= 0)

Applied it.

Thanks,
Chanwoo Choi

Acked-by on v1 1/1
#17 lore raw
In reply to Andrzej Hajda
Quoted 8 lines · Andrzej Hajda

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Please add here

Fixes fc48866f7 ('net/mlx4: Adapt code for N-Port VF')
Quoted 1 line

otherwise, Looks good

Or.

maintainer
#18 lore raw

From: Or Gerlitz <[email protected]>
Date: Tue, 15 Dec 2015 11:09:40 +0200

Quoted 12 lines · Andrzej Hajda
Quoted 8 lines

The function can return negative values, so its result should be assigned to signed variable.

The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1].

[1]: http://permalink.gmane.org/gmane.linux.kernel/2046107

Please add here

Quoted 7 lines
Fixes fc48866f7 ('net/mlx4: Adapt code for N-Port VF')
Quoted 1 line

otherwise, Looks good

Applied with Fixes tag added.