* [PATCH] usb: gadget: add error handling for platform_get_resource_byname
@ 2018-06-12 4:32 Zhouyang Jia
2018-06-12 8:55 ` Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12 4:32 UTC (permalink / raw)
Cc: Zhouyang Jia, Felipe Balbi, Greg Kroah-Hartman, Nicolas Ferre,
Kees Cook, Allen Pais, linux-usb, linux-kernel
When platform_get_resource_byname fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling platform_get_resource_byname.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/usb/gadget/udc/r8a66597-udc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
index a3ecce6..a7bd5e7 100644
--- a/drivers/usb/gadget/udc/r8a66597-udc.c
+++ b/drivers/usb/gadget/udc/r8a66597-udc.c
@@ -1830,6 +1830,11 @@ static int r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597,
struct resource *res;
res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sudmac");
+ if (!res) {
+ dev_err(&pdev->dev, "could not allocate resource.\n");
+ return -ENODEV;
+ }
+
r8a66597->sudmac_reg = devm_ioremap_resource(&pdev->dev, res);
return PTR_ERR_OR_ZERO(r8a66597->sudmac_reg);
}
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] usb: gadget: add error handling for platform_get_resource_byname
2018-06-12 4:32 [PATCH] usb: gadget: add error handling for platform_get_resource_byname Zhouyang Jia
@ 2018-06-12 8:55 ` Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2018-06-12 8:55 UTC (permalink / raw)
To: Zhouyang Jia
Cc: Felipe Balbi, Greg Kroah-Hartman, Nicolas Ferre, Kees Cook,
Allen Pais, linux-usb, linux-kernel
Hello!
On 6/12/2018 7:32 AM, Zhouyang Jia wrote:
> When platform_get_resource_byname fails, the lack of error-handling code may
> cause unexpected results.
What results?
> This patch adds error-handling code after calling platform_get_resource_byname.
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> drivers/usb/gadget/udc/r8a66597-udc.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c
> index a3ecce6..a7bd5e7 100644
> --- a/drivers/usb/gadget/udc/r8a66597-udc.c
> +++ b/drivers/usb/gadget/udc/r8a66597-udc.c
> @@ -1830,6 +1830,11 @@ static int r8a66597_sudmac_ioremap(struct r8a66597 *r8a66597,
> struct resource *res;
>
> res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "sudmac");
> + if (!res) {
> + dev_err(&pdev->dev, "could not allocate resource.\n");
> + return -ENODEV;
> + }
> +
> r8a66597->sudmac_reg = devm_ioremap_resource(&pdev->dev, res);
This function checks for 'res == NULL', no?
> return PTR_ERR_OR_ZERO(r8a66597->sudmac_reg);
> }
MBR, Sergei
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-12 8:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 4:32 [PATCH] usb: gadget: add error handling for platform_get_resource_byname Zhouyang Jia
2018-06-12 8:55 ` Sergei Shtylyov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®