diff mbox

[trusty] (upstream) net/mlx5e: Avoid NULL pointer access in case of configuration failure

Message ID 1458129055-5999-1-git-send-email-talatb@mellanox.com
State New
Headers show

Commit Message

Talat Batheesh March 16, 2016, 11:50 a.m. UTC
From: Achiad Shochat <achiad@mellanox.com>

BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1528466

In case a configuration operation that involves closing and re-opening
resources (e.g RX/TX queue size change) fails at the re-opening stage
these resources will remain closed.
So when executing (following) configuration operations (e.g ifconfig
down) we cannot assume that these resources are available.

Signed-off-by: Achiad Shochat <achiad@mellanox.com>
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit a1985740904342a884471348f6e038ee5d706c36)
Signed-off-by: Talat Batheesh <talatb@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Tim Gardner March 17, 2016, 11:29 a.m. UTC | #1
This patch is actually for Wily.
Brad Figg March 23, 2016, 4:24 a.m. UTC | #2
On Wed, Mar 16, 2016 at 01:50:55PM +0200, Talat Batheesh wrote:
> From: Achiad Shochat <achiad@mellanox.com>
> 
> BugLink: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1528466
> 
> In case a configuration operation that involves closing and re-opening
> resources (e.g RX/TX queue size change) fails at the re-opening stage
> these resources will remain closed.
> So when executing (following) configuration operations (e.g ifconfig
> down) we cannot assume that these resources are available.
> 
> Signed-off-by: Achiad Shochat <achiad@mellanox.com>
> Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> (cherry picked from commit a1985740904342a884471348f6e038ee5d706c36)
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> index 876c0e1..521a97d 100644
> --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
> @@ -1561,6 +1561,12 @@ int mlx5e_close_locked(struct net_device *netdev)
>  {
>  	struct mlx5e_priv *priv = netdev_priv(netdev);
>  
> +	/* May already be CLOSED in case a previous configuration operation
> +	 * (e.g RX/TX queue size change) that involves close&open failed.
> +	 */
> +	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
> +		return 0;
> +
>  	clear_bit(MLX5E_STATE_OPENED, &priv->state);
>  
>  	mlx5e_set_rx_mode_core(priv);
> -- 
> 2.5.0
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Brad Figg March 29, 2016, 5:37 p.m. UTC | #3
Applied to Wily master-next.
diff mbox

Patch

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 876c0e1..521a97d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -1561,6 +1561,12 @@  int mlx5e_close_locked(struct net_device *netdev)
 {
 	struct mlx5e_priv *priv = netdev_priv(netdev);
 
+	/* May already be CLOSED in case a previous configuration operation
+	 * (e.g RX/TX queue size change) that involves close&open failed.
+	 */
+	if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
+		return 0;
+
 	clear_bit(MLX5E_STATE_OPENED, &priv->state);
 
 	mlx5e_set_rx_mode_core(priv);