diff mbox series

dmaengine: idxd: off by one in cleanup code

Message ID X9nFeojulsNqUSnG@mwanda (mailing list archive)
State Accepted
Headers show
Series dmaengine: idxd: off by one in cleanup code | expand

Commit Message

Dan Carpenter Dec. 16, 2020, 8:29 a.m. UTC
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 <dan.carpenter@oracle.com>
---
 drivers/dma/idxd/sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Dave Jiang Dec. 16, 2020, 4:22 p.m. UTC | #1
On Wed, 16 Dec 2020 11:29:46 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> 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 <dan.carpenter@oracle.com>

Acked-by: Dave Jiang <dave.jiang@intel.com>

Thanks Dan!

> ---
>  drivers/dma/idxd/sysfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
> index 266423a2cabc..4dbb03c545e4 100644
> --- a/drivers/dma/idxd/sysfs.c
> +++ b/drivers/dma/idxd/sysfs.c
> @@ -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;
>  }
Vinod Koul Dec. 21, 2020, 1:59 p.m. UTC | #2
On 16-12-20, 11:29, Dan Carpenter wrote:
> 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
diff mbox series

Patch

diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index 266423a2cabc..4dbb03c545e4 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -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;
 }