Skip to contentSkip to conversation

dmaengine: idxd: off by one in cleanup code

PATCH Applied Dan Carpenter 3 participants 3 messages Dec 16, 2020 – Dec 21, 2020

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

PATCH 1/1 dmaengine: idxd: off by one in cleanup code

The clean up is off by one so this will start at "i" and it should start with "i - 1" and then it doesn't unregister the zeroeth elements in the array.

Fixes c52ca478233c ("dmaengine: idxd: add configuration component of driver")
---
 drivers/dma/idxd/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/idxd/sysfs.c +2 -2
index 266423a2cabc..4dbb03c545e4 100644
@@ -434,7 +434,7 @@ int idxd_register_driver(void)
 	return 0;
 
 drv_fail:
-	for (; i > 0; i--)
+	while (--i >= 0)
 		driver_unregister(&idxd_drvs[i]->drv);
 	return rc;
 }
@@ -1840,7 +1840,7 @@ int idxd_register_bus_type(void)
 	return 0;
 
 bus_err:
-	for (; i > 0; i--)
+	while (--i >= 0)
 		bus_unregister(idxd_bus_types[i]);
 	return rc;
 }
Signature · 1 line
2.29.2
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · On Wed, 16 Dec 2020 11:29:46 +0300 Dan Carpenter <[email protected]>…

The clean up is off by one so this will start at "i" and it should start with "i - 1" and then it doesn't unregister the zeroeth elements in the array.

Fixes c52ca478233c ("dmaengine: idxd: add configuration component of

driver") Signed-off-by: Dan Carpenter <[email protected]>

Thanks Dan!

Quoted 26 lines
---
 drivers/dma/idxd/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/dma/idxd/sysfs.c +2 -2
index 266423a2cabc..4dbb03c545e4 100644
@@ -434,7 +434,7 @@ int idxd_register_driver(void)
 	return 0;
 
 drv_fail:
-	for (; i > 0; i--)
+	while (--i >= 0)
 		driver_unregister(&idxd_drvs[i]->drv);
 	return rc;
 }
@@ -1840,7 +1840,7 @@ int idxd_register_bus_type(void)
 	return 0;
 
 bus_err:
-	for (; i > 0; i--)
+	while (--i >= 0)
 		bus_unregister(idxd_bus_types[i]);
 	return rc;
 }
maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 3 lines · Dan Carpenter

The clean up is off by one so this will start at "i" and it should start with "i - 1" and then it doesn't unregister the zeroeth elements in the array.

Applied, thanks

Signature · 1 line
~Vinod