* [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe
@ 2023-06-06 8:19 Dan Carpenter
2023-06-06 9:13 ` Uwe Kleine-König
2023-06-06 9:41 ` Dan Carpenter
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-06-06 8:19 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Uwe Kleine-König, Rob Herring, Felipe Balbi,
Raviteja Garimella, linux-usb, kernel-janitors
The irq_of_parse_and_map() function returns negative error codes
but "udc->irq" is an unsigned int so the error handling doesn't work.
Fixes: 1b9f35adb0ff ("usb: gadget: udc: Add Synopsys UDC Platform driver")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/usb/gadget/udc/snps_udc_plat.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
index 0ed685db149d..37edd6c35077 100644
--- a/drivers/usb/gadget/udc/snps_udc_plat.c
+++ b/drivers/usb/gadget/udc/snps_udc_plat.c
@@ -103,7 +103,7 @@ static int udc_plat_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct resource *res;
struct udc *udc;
- int ret;
+ int irq, ret;
udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL);
if (!udc)
@@ -132,11 +132,12 @@ static int udc_plat_probe(struct platform_device *pdev)
udc->phys_addr = (unsigned long)res->start;
- udc->irq = irq_of_parse_and_map(dev->of_node, 0);
- if (udc->irq <= 0) {
+ irq = irq_of_parse_and_map(dev->of_node, 0);
+ if (irq <= 0) {
dev_err(dev, "Can't parse and map interrupt\n");
return -EINVAL;
}
+ udc->irq = irq;
udc->udc_phy = devm_of_phy_get_by_index(dev, dev->of_node, 0);
if (IS_ERR(udc->udc_phy)) {
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe
2023-06-06 8:19 [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe Dan Carpenter
@ 2023-06-06 9:13 ` Uwe Kleine-König
2023-06-06 9:41 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2023-06-06 9:13 UTC (permalink / raw)
To: Dan Carpenter
Cc: Greg Kroah-Hartman, Rob Herring, Felipe Balbi, Raviteja Garimella,
linux-usb, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 583 bytes --]
On Tue, Jun 06, 2023 at 11:19:46AM +0300, Dan Carpenter wrote:
> The irq_of_parse_and_map() function returns negative error codes
> but "udc->irq" is an unsigned int so the error handling doesn't work.
>
> Fixes: 1b9f35adb0ff ("usb: gadget: udc: Add Synopsys UDC Platform driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Thanks
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | https://www.pengutronix.de/ |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe
2023-06-06 8:19 [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe Dan Carpenter
2023-06-06 9:13 ` Uwe Kleine-König
@ 2023-06-06 9:41 ` Dan Carpenter
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2023-06-06 9:41 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Uwe Kleine-König, Rob Herring, Felipe Balbi,
Raviteja Garimella, linux-usb, kernel-janitors
On Tue, Jun 06, 2023 at 11:19:46AM +0300, Dan Carpenter wrote:
> The irq_of_parse_and_map() function returns negative error codes
> but "udc->irq" is an unsigned int so the error handling doesn't work.
>
> Fixes: 1b9f35adb0ff ("usb: gadget: udc: Add Synopsys UDC Platform driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
> ---
> drivers/usb/gadget/udc/snps_udc_plat.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/snps_udc_plat.c b/drivers/usb/gadget/udc/snps_udc_plat.c
> index 0ed685db149d..37edd6c35077 100644
> --- a/drivers/usb/gadget/udc/snps_udc_plat.c
> +++ b/drivers/usb/gadget/udc/snps_udc_plat.c
> @@ -103,7 +103,7 @@ static int udc_plat_probe(struct platform_device *pdev)
> struct device *dev = &pdev->dev;
> struct resource *res;
> struct udc *udc;
> - int ret;
> + int irq, ret;
>
> udc = devm_kzalloc(dev, sizeof(*udc), GFP_KERNEL);
> if (!udc)
> @@ -132,11 +132,12 @@ static int udc_plat_probe(struct platform_device *pdev)
>
> udc->phys_addr = (unsigned long)res->start;
>
> - udc->irq = irq_of_parse_and_map(dev->of_node, 0);
> - if (udc->irq <= 0) {
> + irq = irq_of_parse_and_map(dev->of_node, 0);
> + if (irq <= 0) {
Oops. It turns out that irq_of_parse_and_map() returns zero on error,
not negatives so this patch isn't needed and probably the correct thing
is to change the error check to if (!irq) { instead.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-06 9:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-06 8:19 [PATCH] usb: gadget/snps_udc_plat: Fix a signedness bug in probe Dan Carpenter
2023-06-06 9:13 ` Uwe Kleine-König
2023-06-06 9:41 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox