public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
* [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port
@ 2015-12-14 10:05 Andrzej Hajda
  2015-12-14 10:06 ` [PATCH] ath9k_htc: fix handling return value of ath9k_hw_calibrate Andrzej Hajda
  2015-12-15  9:09 ` [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port Or Gerlitz
  0 siblings, 2 replies; 5+ messages in thread
From: Andrzej Hajda @ 2015-12-14 10:05 UTC (permalink / raw)
  To: Or Gerlitz, Jack Morgenstein
  Cc: Andrzej Hajda, Bartlomiej Zolnierkiewicz, Marek Szyprowski,
	David S. Miller, Eran Ben Elisha, Hadar Hen Zion, Moni Shoua,
	Yishai Hadas, Maor Gottlieb, netdev, linux-kernel

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 <a.hajda@samsung•com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-12-31 13:12 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-14 10:05 [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port Andrzej Hajda
2015-12-14 10:06 ` [PATCH] ath9k_htc: fix handling return value of ath9k_hw_calibrate Andrzej Hajda
     [not found]   ` <1450087564-28441-4-git-send-email-a.hajda-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2015-12-31 13:12     ` Kalle Valo
2015-12-15  9:09 ` [PATCH] net/mlx4_core: fix handling return value of mlx4_slave_convert_port Or Gerlitz
2015-12-15 16:55   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox