Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2285968img; Sun, 24 Mar 2019 04:53:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyiOiGTyHvQj/jmJZLkd4rqvbr0kV2lzuC4f+wLogpxbUXvgmVUkGTrH9GVnxrQWddKWLEm X-Received: by 2002:a62:4290:: with SMTP id h16mr18836564pfd.8.1553428391779; Sun, 24 Mar 2019 04:53:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553428391; cv=none; d=google.com; s=arc-20160816; b=B5pY/RzMLQTiHCrXHJcHSPg/u6fWgJnGKEFT89X30x0/VQV85WkE06YaxcWdEzLHVD pk82hhuT7eFo9imFHgfPm0+B0gd4ypb0XuzHfwfNOkD/R36jwJkXkBevgtJvOLgHKjtD /DJ73fZpylaLiQsH5hONA5sfVR9l6uCyxjEYXaasBL2SfuTP9E897SMf17HL4AreHBFF bNX+wUrvtSMfve/owoVprS0t2eH1/y0yuA/lg+4+w9jcqS7p9Z7unMSBLPgYAn/YjO7W HJr3czONhnLxiSjaABGdFU5uSU8XtX0uogIAbRLCSrloPE7De/onI3hw/Bj+TlmkBHla ndrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=kXlUnh+mxk2GWFPfDj5QfkjtTxcYQUHgYQLz7ErjaaU=; b=tD3mjfu5XHEqnzX3lRhjF/tncL4MJYfZzy6vfHQLeuRBWnqz2saoFGz99K4coYxKad PoUVV9P7AUC/fvE2mMpCugCEUg5y6pzDToQawwk9fD1nZFVs84Um+tWl2p7b90lzgO1Y 4M9bUwf+V7Kyv1I7kxeaFLhmV65JZQPY2rpfo4lJy+BhgSKmGXBXjz8UinV4jORn6/0U zTSGYYwbpX4RmIFGpOgRfMWBptGSBSED5zIAPFzgqNwBYcfVtwzHoOGlV14cJH3VPUVd td4o03+Q9QgALTYxFssRbLoRlFe/kg5RN4Eiyrk6t6Y0rBIzyyxYmvqFasFiOem8Nr0i y/Pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cs11si13373607plb.248.2019.03.24.04.52.56; Sun, 24 Mar 2019 04:53:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728644AbfCXLuU (ORCPT + 99 others); Sun, 24 Mar 2019 07:50:20 -0400 Received: from saturn.retrosnub.co.uk ([46.235.226.198]:36794 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726160AbfCXLuT (ORCPT ); Sun, 24 Mar 2019 07:50:19 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) by saturn.retrosnub.co.uk (Postfix; Retrosnub mail submission) with ESMTPSA id 01C8D9E758A; Sun, 24 Mar 2019 11:50:17 +0000 (GMT) Date: Sun, 24 Mar 2019 11:50:15 +0000 From: Jonathan Cameron To: Kangjie Lu Cc: pakki001@umn.edu, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] iio: hmc5843: fix potential NULL pointer dereferences Message-ID: <20190324115015.5fe793ad@archlinux> In-Reply-To: <20190324104856.3883150b@archlinux> References: <20190316151912.4a7ea87d@archlinux> <20190316220836.25092-1-kjlu@umn.edu> <20190324104856.3883150b@archlinux> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 24 Mar 2019 10:48:56 +0000 Jonathan Cameron wrote: > On Sat, 16 Mar 2019 17:08:33 -0500 > 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 > Applied to the togreg branch of iio.git and pushed out as testing > for the autobuilders to play with it. > Thanks. Ah, how the eye jumps over the obvious... Good thing this one was caught by build tests. See below. I've fixed up in the tree. Jonathan > > Jonathan > > > --- > > V2: fix the two together > > --- > > drivers/iio/magnetometer/hmc5843_i2c.c | 7 ++++++- > > drivers/iio/magnetometer/hmc5843_spi.c | 7 ++++++- > > 2 files changed, 12 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/magnetometer/hmc5843_i2c.c > > index 3de7f4426ac4..86abba5827a2 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 *regmap = devm_regmap_init_i2c(cli, > > + &hmc5843_i2c_regmap_config); > > + if (IS_ERR(regmap)) > > + return PTR_ERR(regmap); > > + > > return hmc5843_common_probe(&cli->dev, > > - devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config), > > + regmap, > > id->driver_data, id->name); > > } > > > > diff --git a/drivers/iio/magnetometer/hmc5843_spi.c b/drivers/iio/magnetometer/hmc5843_spi.c > > index 535f03a70d63..8355713651d4 100644 > > --- a/drivers/iio/magnetometer/hmc5843_spi.c > > +++ b/drivers/iio/magnetometer/hmc5843_spi.c > > @@ -58,6 +58,7 @@ static const struct regmap_config hmc5843_spi_regmap_config = { > > static int hmc5843_spi_probe(struct spi_device *spi) > > { > > int ret; > > + struct regmap *regmap; > > const struct spi_device_id *id = spi_get_device_id(spi); > > > > spi->mode = SPI_MODE_3; > > @@ -67,8 +68,12 @@ static int hmc5843_spi_probe(struct spi_device *spi) > > if (ret) > > return ret; > > > > + regmap = devm_regmap_init(spi, &hmc5843_spi_regmap_config); devm_regmap_init_spi > > + if (IS_ERR(regmap)) > > + return PTR_ERR(devm_regmap); It's called regmap. > > + > > return hmc5843_common_probe(&spi->dev, > > - devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config), > > + regmap, > > id->driver_data, id->name); > > } > > >