All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Dan Carpenter <dan.carpenter@oracle.com>,
	Marek Belisko <marek@goldelico.com>
Cc: Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] iio: inkern: fix a NULL dereference on error
Date: Sat, 30 Jan 2016 15:39:17 +0000	[thread overview]
Message-ID: <56ACD925.3010006@kernel.org> (raw)
In-Reply-To: <20160126092521.GC15717@mwanda>

On 26/01/16 09:25, Dan Carpenter wrote:
> In twl4030_bci_probe() there are some failure paths where we call
> iio_channel_release() with a NULL pointer.  (Apparently, that driver can
> opperate without a valid channel pointer).  Let's fix it by adding a
> NULL check in iio_channel_release().
> 
> Fixes: 2202e1fc5a29 ('drivers: power: twl4030_charger: fix link problems when building as module')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
Whilst I'd prefer to see the driver calling this have balanced
calls, I can see that having this sanity check in here is
probably sensible.

Applied to the fixes-togreg tree and marked for stable.

Jonathan
> diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c
> index 80fbbfd..734a004 100644
> --- a/drivers/iio/inkern.c
> +++ b/drivers/iio/inkern.c
> @@ -349,6 +349,8 @@ EXPORT_SYMBOL_GPL(iio_channel_get);
>  
>  void iio_channel_release(struct iio_channel *channel)
>  {
> +	if (!channel)
> +		return;
>  	iio_device_put(channel->indio_dev);
>  	kfree(channel);
>  }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


      reply	other threads:[~2016-01-30 15:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-26  9:25 [patch] iio: inkern: fix a NULL dereference on error Dan Carpenter
2016-01-26  9:25 ` Dan Carpenter
2016-01-30 15:39 ` Jonathan Cameron [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=56ACD925.3010006@kernel.org \
    --to=jic23@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marek@goldelico.com \
    --cc=pmeerw@pmeerw.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.