lkml.org 
[lkml]   [2018]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] usb: gadget: add error handling for platform_get_resource_byname
From
Date
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

\
 
 \ /
  Last update: 2018-06-12 10:56    [W:0.025 / U:12.072 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site