2015-12-14 10:07:31

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] 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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index da7f578..b46dbe2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -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) {
--
1.9.1


2015-12-14 10:07:40

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] doc: mei: fix handling return value of mei_recv_msg

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

Signed-off-by: Andrzej Hajda <[email protected]>
---
Documentation/misc-devices/mei/mei-amt-version.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/misc-devices/mei/mei-amt-version.c b/Documentation/misc-devices/mei/mei-amt-version.c
index 57d0d87..33e67bd 100644
--- a/Documentation/misc-devices/mei/mei-amt-version.c
+++ b/Documentation/misc-devices/mei/mei-amt-version.c
@@ -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;
--
1.9.1

2015-12-14 10:07:51

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] 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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/clk/sunxi/clk-sun8i-bus-gates.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clk/sunxi/clk-sun8i-bus-gates.c b/drivers/clk/sunxi/clk-sun8i-bus-gates.c
index 7ab60c5..ecadd97 100644
--- a/drivers/clk/sunxi/clk-sun8i-bus-gates.c
+++ b/drivers/clk/sunxi/clk-sun8i-bus-gates.c
@@ -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);
--
1.9.1

2015-12-14 10:07:57

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] ath9k_htc: fix handling return value of ath9k_hw_calibrate

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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/net/wireless/ath/ath9k/htc_drv_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index a680a97..fe1fd1a 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -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);
}
--
1.9.1

2015-12-14 10:08:52

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] extcon: max14577: fix handling return value of regmap_irq_get_virq

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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/extcon/extcon-max14577.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
index 601dbd9..b30ab97 100644
--- a/drivers/extcon/extcon-max14577.c
+++ b/drivers/extcon/extcon-max14577.c
@@ -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)
--
1.9.1

2015-12-14 10:08:04

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] extcon: max77843: fix handling return value of regmap_irq_get_virq

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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/extcon/extcon-max77843.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
index 9f9ea33..74dfb7f 100644
--- a/drivers/extcon/extcon-max77843.c
+++ b/drivers/extcon/extcon-max77843.c
@@ -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);
--
1.9.1

2015-12-14 10:08:11

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] be2iscsi: fix handling return value of mgmt_open_connection

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

Signed-off-by: Andrzej Hajda <[email protected]>
---
drivers/scsi/be2iscsi/be_iscsi.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index b7087ba..ce9f192 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -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");
--
1.9.1

2015-12-14 10:30:47

by Krzysztof Kozlowski

[permalink] [raw]
Subject: 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]>:
> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> drivers/extcon/extcon-max77843.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2015-12-14 10:31:45

by Krzysztof Kozlowski

[permalink] [raw]
Subject: 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]>:
> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Do you plan to fix also max77693?

Best regards,
Krzysztof

2015-12-14 11:15:08

by Andrzej Hajda

[permalink] [raw]
Subject: [PATCH] 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.

Signed-off-by: Andrzej Hajda <[email protected]>
Suggested-by: Krzysztof Kozlowski <[email protected]>
---
drivers/extcon/extcon-max77693.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
index 44c499e..fdf8f5d 100644
--- a/drivers/extcon/extcon-max77693.c
+++ b/drivers/extcon/extcon-max77693.c
@@ -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;

--
1.9.1

2015-12-14 12:04:45

by Winkler, Tomas

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

> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> Documentation/misc-devices/mei/mei-amt-version.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/misc-devices/mei/mei-amt-version.c
> b/Documentation/misc-devices/mei/mei-amt-version.c
> index 57d0d87..33e67bd 100644
> --- a/Documentation/misc-devices/mei/mei-amt-version.c
> +++ b/Documentation/misc-devices/mei/mei-amt-version.c
> @@ -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.
> - 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

2015-12-14 13:05:20

by Maxime Ripard

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

Hi,

On Mon, Dec 14, 2015 at 11:06:00AM +0100, Andrzej Hajda wrote:
> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>

Applied, thanks!
Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com


Attachments:
(No filename) (548.00 B)
signature.asc (819.00 B)
Digital signature
Download all attachments

2015-12-15 00:23:00

by Krzysztof Kozlowski

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

On 14.12.2015 20:12, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> Suggested-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/extcon/extcon-max77693.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2015-12-15 01:08:44

by Chanwoo Choi

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

On 2015년 12월 14일 19:06, Andrzej Hajda wrote:
> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> drivers/extcon/extcon-max14577.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/extcon/extcon-max14577.c b/drivers/extcon/extcon-max14577.c
> index 601dbd9..b30ab97 100644
> --- a/drivers/extcon/extcon-max14577.c
> +++ b/drivers/extcon/extcon-max14577.c
> @@ -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

2015-12-15 01:08:51

by Chanwoo Choi

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

On 2015년 12월 14일 20:12, Andrzej Hajda wrote:
> The function can return negative values, so its result should
> be assigned to signed variable.
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> Suggested-by: Krzysztof Kozlowski <[email protected]>
> ---
> drivers/extcon/extcon-max77693.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/extcon/extcon-max77693.c b/drivers/extcon/extcon-max77693.c
> index 44c499e..fdf8f5d 100644
> --- a/drivers/extcon/extcon-max77693.c
> +++ b/drivers/extcon/extcon-max77693.c
> @@ -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;
>
>

Applied it.

Thanks,
Chanwoo Choi

2015-12-15 01:09:10

by Chanwoo Choi

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

On 2015년 12월 14일 19:06, Andrzej Hajda wrote:
> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>
> ---
> drivers/extcon/extcon-max77843.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/extcon/extcon-max77843.c b/drivers/extcon/extcon-max77843.c
> index 9f9ea33..74dfb7f 100644
> --- a/drivers/extcon/extcon-max77843.c
> +++ b/drivers/extcon/extcon-max77843.c
> @@ -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

2015-12-15 09:10:06

by Or Gerlitz

[permalink] [raw]
Subject: Re: [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port

On 12/14/2015 12:05 PM, Andrzej Hajda wrote:
> 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')


> Signed-off-by: Andrzej Hajda <[email protected]>

otherwise, Looks good

Acked-by: Or Gerlitz <[email protected]>

Or.

2015-12-15 16:55:20

by David Miller

[permalink] [raw]
Subject: Re: [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port

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

> On 12/14/2015 12:05 PM, Andrzej Hajda wrote:
>> 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')
>
>> Signed-off-by: Andrzej Hajda <[email protected]>
>
> otherwise, Looks good
>
> Acked-by: Or Gerlitz <[email protected]>

Applied with Fixes tag added.

2015-12-31 13:12:58

by Kalle Valo

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

Andrzej Hajda <[email protected]> writes:

> 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
>
> Signed-off-by: Andrzej Hajda <[email protected]>

Applied to ath.git, thanks.

--
Kalle Valo