linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning
@ 2016-10-25 16:16 Arnd Bergmann
  2016-10-26  6:51 ` Yishai Hadas
  2016-12-14 17:13 ` Doug Ledford
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-10-25 16:16 UTC (permalink / raw)
  To: Yishai Hadas
  Cc: Arnd Bergmann, David S. Miller, Jack Morgenstein, Or Gerlitz,
	Eran Ben Elisha, Moshe Shemesh, Christophe Jaillet, Moni Shoua,
	netdev, linux-rdma, linux-kernel

There is an old warning about mlx4_SW2HW_EQ_wrapper on x86:

ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:
ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]

The problem here is that gcc won't track the state of the variable
across a spin_unlock. Moving the assignment out of the lock is
safe here and avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 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 84d7857ccc27..c548beaaf910 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -1605,13 +1605,14 @@ static int eq_res_start_move_to(struct mlx4_dev *dev, int slave, int index,
 			r->com.from_state = r->com.state;
 			r->com.to_state = state;
 			r->com.state = RES_EQ_BUSY;
-			if (eq)
-				*eq = r;
 		}
 	}
 
 	spin_unlock_irq(mlx4_tlock(dev));
 
+	if (!err && eq)
+		*eq = r;
+
 	return err;
 }
 
-- 
2.9.0

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

* Re: [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning
  2016-10-25 16:16 [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning Arnd Bergmann
@ 2016-10-26  6:51 ` Yishai Hadas
  2016-12-14 17:13 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Yishai Hadas @ 2016-10-26  6:51 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Yishai Hadas, David S. Miller, Jack Morgenstein, Or Gerlitz,
	Eran Ben Elisha, Moshe Shemesh, Christophe Jaillet, Moni Shoua,
	netdev, linux-rdma, linux-kernel

On 10/25/2016 7:16 PM, Arnd Bergmann wrote:
> There is an old warning about mlx4_SW2HW_EQ_wrapper on x86:
>
> ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:
> ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> The problem here is that gcc won't track the state of the variable
> across a spin_unlock. Moving the assignment out of the lock is
> safe here and avoids the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Yishai Hadas <yishaih@mellanox.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 84d7857ccc27..c548beaaf910 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> @@ -1605,13 +1605,14 @@ static int eq_res_start_move_to(struct mlx4_dev *dev, int slave, int index,
>  			r->com.from_state = r->com.state;
>  			r->com.to_state = state;
>  			r->com.state = RES_EQ_BUSY;
> -			if (eq)
> -				*eq = r;
>  		}
>  	}
>
>  	spin_unlock_irq(mlx4_tlock(dev));
>
> +	if (!err && eq)
> +		*eq = r;
> +
>  	return err;
>  }
>
>

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

* Re: [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning
  2016-10-25 16:16 [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning Arnd Bergmann
  2016-10-26  6:51 ` Yishai Hadas
@ 2016-12-14 17:13 ` Doug Ledford
  1 sibling, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2016-12-14 17:13 UTC (permalink / raw)
  To: Arnd Bergmann, Yishai Hadas
  Cc: David S. Miller, Jack Morgenstein, Or Gerlitz, Eran Ben Elisha,
	Moshe Shemesh, Christophe Jaillet, Moni Shoua, netdev,
	linux-rdma, linux-kernel


[-- Attachment #1.1: Type: text/plain, Size: 663 bytes --]

On 10/25/2016 12:16 PM, Arnd Bergmann wrote:
> There is an old warning about mlx4_SW2HW_EQ_wrapper on x86:
> 
> ethernet/mellanox/mlx4/resource_tracker.c: In function ‘mlx4_SW2HW_EQ_wrapper’:
> ethernet/mellanox/mlx4/resource_tracker.c:3071:10: error: ‘eq’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
> 
> The problem here is that gcc won't track the state of the variable
> across a spin_unlock. Moving the assignment out of the lock is
> safe here and avoids the warning.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Thanks, applied.

-- 
Doug Ledford <dledford@redhat.com>
    GPG Key ID: 0E572FDD


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 884 bytes --]

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

end of thread, other threads:[~2016-12-14 17:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-25 16:16 [PATCH] IB/mlx4: avoid a -Wmaybe-uninitialize warning Arnd Bergmann
2016-10-26  6:51 ` Yishai Hadas
2016-12-14 17:13 ` Doug Ledford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).