From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Zhouyang Jia <jiazhouyang09@gmail.com>
Cc: 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: Re: [PATCH] usb: gadget: add error handling for platform_get_resource_byname
Date: Tue, 12 Jun 2018 11:55:15 +0300 [thread overview]
Message-ID: <e6291d56-477e-980a-a8b4-de86e85d3851@cogentembedded.com> (raw)
In-Reply-To: <1528777942-40876-1-git-send-email-jiazhouyang09@gmail.com>
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
prev parent reply other threads:[~2018-06-12 8:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-12 4:32 Zhouyang Jia
2018-06-12 8:55 ` Sergei Shtylyov [this message]
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=e6291d56-477e-980a-a8b4-de86e85d3851@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=allen.lkml@gmail.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=jiazhouyang09@gmail.com \
--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®