mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vlynq : Handle return value of platform_get_irq_byname and vlynq_probe
Date: Fri, 17 Nov 2017 08:49:40 -0800	[thread overview]
Message-ID: <a1e65999-aa59-e7f9-f715-72695249edf6@gmail.com> (raw)
In-Reply-To: <1d87b593fd57869ad42701df6c3087efa9e74c94.1510935630.git.arvind.yadav.cs@gmail.com>

On 11/17/2017 08:21 AM, Arvind Yadav wrote:
> platform_get_irq_byname() can fail here and we must check its return value.
> 
> device_register() can fail here, initialised 'result' variable
> beforen'goto fail_register' otherwise vlynq_probe will return uninitialised
> 'result' variable.
> 
> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> ---
>  drivers/vlynq/vlynq.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/vlynq/vlynq.c b/drivers/vlynq/vlynq.c
> index c0227f9..bc735f9 100644
> --- a/drivers/vlynq/vlynq.c
> +++ b/drivers/vlynq/vlynq.c
> @@ -722,13 +722,19 @@ static int vlynq_probe(struct platform_device *pdev)
>  					    VLYNQ_REMOTE_OFFSET);
>  
>  	dev->irq = platform_get_irq_byname(pdev, "irq");
> +	if (dev->irq < 0) {
> +		result = dev->irq;
> +		goto fail_register;
> +	}

That part looks fine.

>  	dev->irq_start = irq_res->start;
>  	dev->irq_end = irq_res->end;
>  	dev->local_irq = dev->irq_end - dev->irq_start;
>  	dev->remote_irq = dev->local_irq - 1;
>  
> -	if (device_register(&dev->dev))
> +	if (device_register(&dev->dev)) {
> +		result = -ENXIO;
>  		goto fail_register;
> +	}

However here, we should propagate the return value of device_register()
to be consistent with the changes earlier.

>  	platform_set_drvdata(pdev, dev);
>  
>  	printk(KERN_INFO "%s: regs 0x%p, irq %d, mem 0x%p\n",
> 

-- 
Florian

      reply	other threads:[~2017-11-17 16:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 16:21 Arvind Yadav
2017-11-17 16:49 ` Florian Fainelli [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=a1e65999-aa59-e7f9-f715-72695249edf6@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=arvind.yadav.cs@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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®