All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Kangjie Lu <kjlu@umn.edu>
Cc: Tomasz Duszynski <tduszyns@gmail.com>,
	pakki001@umn.edu, Hartmut Knaack <knaack.h@gmx.de>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: hmc: fix a potential NULL pointer dereference
Date: Sat, 16 Mar 2019 15:19:12 +0000	[thread overview]
Message-ID: <20190316151912.4a7ea87d@archlinux> (raw)
In-Reply-To: <57617810-6F1A-41BF-889C-7A056423C360@umn.edu>

On Tue, 12 Mar 2019 02:19:25 -0500
Kangjie Lu <kjlu@umn.edu> wrote:

> > On Mar 9, 2019, at 12:29 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> > 
> > On Sat, 9 Mar 2019 14:42:09 +0100
> > Tomasz Duszynski <tduszyns@gmail.com <mailto:tduszyns@gmail.com>> wrote:
> >   
> >> On Fri, Mar 08, 2019 at 11:15:32PM -0600, Kangjie Lu wrote:  
> >>> devm_regmap_init_i2c may fail and return NULL. The fix returns
> >>> the error when it fails.
> >>> 
> >>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> >>> ---
> >>> drivers/iio/magnetometer/hmc5843_i2c.c | 7 ++++++-
> >>> 1 file changed, 6 insertions(+), 1 deletion(-)
> >>> 
> >>> diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c
> >>> index 3de7f4426ac4..c0cd0823f8d5 100644
> >>> --- a/drivers/iio/magnetometer/hmc5843_i2c.c
> >>> +++ b/drivers/iio/magnetometer/hmc5843_i2c.c
> >>> @@ -58,8 +58,13 @@ static const struct regmap_config hmc5843_i2c_regmap_config = {
> >>> static int hmc5843_i2c_probe(struct i2c_client *cli,
> >>> 			     const struct i2c_device_id *id)
> >>> {
> >>> +	struct regmap *devm_regmap = devm_regmap_init_i2c(cli,
> >>> +			&hmc5843_i2c_regmap_config);
> >>> +	if (IS_ERR(devm_regmap))
> >>> +		return PTR_ERR(devm_regmap);    
> >> 
> >> This fixes only one part of the problem leaving identical spi issue
> >> behind. I guess this check should be part of *common_probe().  
> > It could be, but that somewhat hides the error checking.
> > 
> > I'd prefer to see it fixed like this, but in both here and the spi
> > file.  Both this and spi in one patch would be great!  
> 
> I’ve submitted the patch for spi as well.
> 
Ah. I missed it because of inconsistent patch naming.
Anyhow, there were some minor suggestions for that patch so please
send a v2 with the two combined.

Thanks

Jonathan

> > 
> > Thanks,
> > 
> > Jonathan
> >   
> >>   
> >>> +
> >>> 	return hmc5843_common_probe(&cli->dev,
> >>> -			devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config),
> >>> +			devm_regmap,
> >>> 			id->driver_data, id->name);
> >>> }
> >>> 
> >>> --
> >>> 2.17.1  
> 


  parent reply	other threads:[~2019-03-16 15:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-09  5:15 [PATCH] iio: hmc: fix a potential NULL pointer dereference Kangjie Lu
2019-03-09 13:42 ` Tomasz Duszynski
2019-03-09 18:29   ` Jonathan Cameron
     [not found]     ` <57617810-6F1A-41BF-889C-7A056423C360@umn.edu>
2019-03-16 15:19       ` Jonathan Cameron [this message]
2019-03-16 22:08         ` [PATCH v2] iio: hmc5843: fix potential NULL pointer dereferences Kangjie Lu
2019-03-24 10:48           ` Jonathan Cameron
2019-03-24 11:50             ` Jonathan Cameron

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=20190316151912.4a7ea87d@archlinux \
    --to=jic23@kernel.org \
    --cc=kjlu@umn.edu \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pakki001@umn.edu \
    --cc=pmeerw@pmeerw.net \
    --cc=tduszyns@gmail.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 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.