From: Zhouyang Jia <jiazhouyang09@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: Zhouyang Jia <jiazhouyang09@gmail.com>,
Felipe Balbi <balbi@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Nicolas Ferre <nicolas.ferre@microchip.com>,
Kees Cook <keescook@chromium.org>,
Allen Pais <allen.lkml@gmail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] usb: gadget: add error handling for platform_get_resource_byname
Date: Tue, 12 Jun 2018 12:32:19 +0800 [thread overview]
Message-ID: <1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com> (raw)
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
next reply other threads:[~2018-06-12 4:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 4:32 Zhouyang Jia [this message]
2018-06-12 8:55 ` Sergei Shtylyov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com \
--to=jiazhouyang09@gmail.com \
--cc=allen.lkml@gmail.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nicolas.ferre@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®