lkml.org 
[lkml]   [2018]   [Jun]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] usb: gadget: add error handling for platform_get_resource_byname
Date
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
\
 
 \ /
  Last update: 2018-06-12 06:33    [W:0.026 / U:2.608 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site