Skip to contentSkip to conversation

platform/x86: mlx-platform: free first dev on error

PATCH In review Dan Carpenter 2 participants 2 messages Jan 7, 2017

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

PATCH 1/1 platform/x86: mlx-platform: free first dev on error

There is an off-by-one error so we don't unregister priv->pdev_mux[0]. Also it's slightly simpler as a while loop instead of a for loop.

Fixes 58cbbee2391c ("x86/platform/mellanox: Introduce support for Mellanox systems platform")
drivers/platform/x86/mlx-platform.c +1 -1
index 04e1f2b30fa6..8f98c211b440 100644
@@ -342,7 +342,7 @@ static int __init mlxplat_init(void)
 	return 0;
 
 fail_platform_mux_register:
-	for (i--; i > 0 ; i--)
+	while (--i >= 0)
 		platform_device_unregister(priv->pdev_mux[i]);
 	platform_device_unregister(priv->pdev_i2c);
 fail_alloc:
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Saturday, January 07, 2017 8:34 AM
To: Vadim Pasternak <[email protected]>
Cc: Darren Hart <[email protected]>; platform-driver- [email protected]; [email protected]
Subject: [patch] platform/x86: mlx-platform: free first dev on error

Quoted 7 lines

There is an off-by-one error so we don't unregister priv->pdev_mux[0]. Also it's slightly simpler as a while loop instead of a for loop.

Fixes 58cbbee2391c ("x86/platform/mellanox: Introduce support for

Mellanox systems platform")

Quoted 14 lines
drivers/platform/x86/mlx- renamed from drivers/platform/x86/mlx-platform.c +0 -0

platform.c
index 04e1f2b30fa6..8f98c211b440 100644

drivers/platform/x86/mlx-platform.c +1 -1
@@ -342,7 +342,7 @@ static int __init mlxplat_init(void)
 	return 0;
 
 fail_platform_mux_register:
-	for (i--; i > 0 ; i--)
+	while (--i >= 0)
 		platform_device_unregister(priv->pdev_mux[i]);
 	platform_device_unregister(priv->pdev_i2c);
 fail_alloc: