2022-06-23 08:52:49

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] usb: gadget: Fix unsigned comparison with less than zero

This was found by coccicheck:

./drivers/usb/gadget/udc/aspeed_udc.c:496:8-13: WARNING: Unsigned expression compared with zero: chunk >= 0.

Signed-off-by: Jiapeng Chong <[email protected]>
---
drivers/usb/gadget/udc/aspeed_udc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/udc/aspeed_udc.c b/drivers/usb/gadget/udc/aspeed_udc.c
index 1fc15228ff15..387a7abdcee4 100644
--- a/drivers/usb/gadget/udc/aspeed_udc.c
+++ b/drivers/usb/gadget/udc/aspeed_udc.c
@@ -476,8 +476,8 @@ static int ast_dma_descriptor_setup(struct ast_udc_ep *ep, u32 dma_buf,
{
struct ast_udc_dev *udc = ep->udc;
struct device *dev = &udc->pdev->dev;
- u32 offset, chunk;
- int count, last;
+ u32 offset;
+ int count, last, chunk;

if (!ep->descs) {
dev_warn(dev, "%s: Empty DMA descs list failure\n",
--
2.20.1.7.g153144c


2022-06-24 12:01:24

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] usb: gadget: Fix unsigned comparison with less than zero

On Thu, Jun 23, 2022 at 04:43:47PM +0800, Jiapeng Chong wrote:
> This was found by coccicheck:
>
> ./drivers/usb/gadget/udc/aspeed_udc.c:496:8-13: WARNING: Unsigned expression compared with zero: chunk >= 0.

What does this mean? Where is the error?

Please explain the reason for changes, not just the output of a random
tool that you ran on the code.

> Signed-off-by: Jiapeng Chong <[email protected]>

What commit does this fix?

thanks,

greg k-h