[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com>
Date: Tue, 12 Jun 2018 12:32:19 +0800
From: Zhouyang Jia <jiazhouyang09@...il.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@...il.com>,
Felipe Balbi <balbi@...nel.org>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Nicolas Ferre <nicolas.ferre@...rochip.com>,
Kees Cook <keescook@...omium.org>,
Allen Pais <allen.lkml@...il.com>, linux-usb@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH] usb: gadget: add error handling for platform_get_resource_byname
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@...il.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
Powered by blists - more mailing lists