netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Heikki Krogerus <heikki.krogerus@linux.intel.com>
To: Johan Hovold <johan@kernel.org>
Cc: Johannes Berg <johannes@sipsolutions.net>,
	"David S. Miller" <davem@davemloft.net>,
	linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable <stable@vger.kernel.org>
Subject: Re: [PATCH] net: rfkill: gpio: fix memory leak in probe error path
Date: Thu, 26 Apr 2018 11:14:48 +0300	[thread overview]
Message-ID: <20180426081448.GB17550@kuha.fi.intel.com> (raw)
In-Reply-To: <20180426073152.7953-1-johan@kernel.org>

On Thu, Apr 26, 2018 at 09:31:52AM +0200, Johan Hovold wrote:
> Make sure to free the rfkill device in case registration fails during
> probe.
> 
> Fixes: 5e7ca3937fbe ("net: rfkill: gpio: convert to resource managed allocation")
> Cc: stable <stable@vger.kernel.org>	# 3.13
> Cc: Heikki Krogerus <heikki.krogerus@linux.intel.com>

Good catch. FWIW:

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> Signed-off-by: Johan Hovold <johan@kernel.org>
> ---
>  net/rfkill/rfkill-gpio.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/net/rfkill/rfkill-gpio.c b/net/rfkill/rfkill-gpio.c
> index 41bd496531d4..00192a996be0 100644
> --- a/net/rfkill/rfkill-gpio.c
> +++ b/net/rfkill/rfkill-gpio.c
> @@ -137,13 +137,18 @@ static int rfkill_gpio_probe(struct platform_device *pdev)
>  
>  	ret = rfkill_register(rfkill->rfkill_dev);
>  	if (ret < 0)
> -		return ret;
> +		goto err_destroy;
>  
>  	platform_set_drvdata(pdev, rfkill);
>  
>  	dev_info(&pdev->dev, "%s device registered.\n", rfkill->name);
>  
>  	return 0;
> +
> +err_destroy:
> +	rfkill_destroy(rfkill->rfkill_dev);
> +
> +	return ret;
>  }
>  
>  static int rfkill_gpio_remove(struct platform_device *pdev)
> -- 
> 2.17.0

-- 
heikki

      reply	other threads:[~2018-04-26  8:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-26  7:31 [PATCH] net: rfkill: gpio: fix memory leak in probe error path Johan Hovold
2018-04-26  8:14 ` Heikki Krogerus [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=20180426081448.GB17550@kuha.fi.intel.com \
    --to=heikki.krogerus@linux.intel.com \
    --cc=davem@davemloft.net \
    --cc=johan@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@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;
as well as URLs for NNTP newsgroup(s).