Received: by 2002:ac0:950e:0:0:0:0:0 with SMTP id f14csp557137imc; Sat, 16 Mar 2019 08:39:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDaQ5GoYLoZObfl7jeok28jv1HmszlAEJisHLNJvGg5WUKQawDCU88EAwLCu74tK2mFUDy X-Received: by 2002:a63:7e03:: with SMTP id z3mr5815008pgc.388.1552750741254; Sat, 16 Mar 2019 08:39:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552750741; cv=none; d=google.com; s=arc-20160816; b=TGItYGVQ/LoapqTkVSsI5xWFevUzqrnAx+Ddw8WhRF4+lJJZwRgb4jywaL3KWHZf+x Uba4W6eCtM3HHRvZ+JCG2uXp/EcxG+Hxl2TzBB/VAzmztyupiZqCMAweGaYM+NLOfwWa 739dEA7mqSiMT4EAGroaqO/HMnUzbIZ5tCWOaX/UPEGBuT0N9ixUKN/XiuYqcSqyjaVA h25F9cEjKBx7JlekmOQp+oi6jm/UdwXlbn6P/FvQnJ4eE9Qh/6uXfPee9K7YF5gZGHOZ bjZLdVx0dXBm9bHlQf3JN/aYOb0mKzii+IqDqS6unSruZyTdGDGGoBtIu7BsSQhUb9CC bW9Q== 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 :dkim-signature; bh=w6OUzIgPPCNsjc1HMCRLhdCJfjFGCLsVjbINu2H9k1I=; b=TjPQ50zouduQEBymqMhh5nhgy6o4QK7z+V1Tyj3hQynhegEAJkgeEv1daYWVJorM4i fg5tNgwJ/PAXJIvj+ntwnhvW4Je/ABXdwSTYycH3+ieK+5Xekb8RWlTgnAHcDmaISkQI HzIrK7c2lQSDfarNwrvQimNLtM62Df+1pZTh3qJUaIxQ1lN+YygKr6TvjSRFfR8X5mde DTWOemRJYrj/y3APnBYkR10eJAMO1NLhKLiekCpuE+m0H5B91bQUTX1ktfaqupeeVcPE XwwMP8BUJpI0Bzn5M8qXsSbTKl1nenrmxRv9tmbkHC3Y3TjbS7KLBU8Nb9mr3QV1pd0a OgaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oh3Qfp0q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7si4833235pfb.153.2019.03.16.08.38.43; Sat, 16 Mar 2019 08:39:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=oh3Qfp0q; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727164AbfCPPTT (ORCPT + 99 others); Sat, 16 Mar 2019 11:19:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:38124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726461AbfCPPTS (ORCPT ); Sat, 16 Mar 2019 11:19:18 -0400 Received: from archlinux (cpc91196-cmbg18-2-0-cust659.5-4.cable.virginm.net [81.96.234.148]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3FB8B20449; Sat, 16 Mar 2019 15:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552749557; bh=gOOpIFtVh5xUu2k7isOm9AZJajRq6QzGqLm65AeifFo=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=oh3Qfp0qkhvw8/3t0OKODyUVJcPDFpxaC5IqmZeFzpsHttN4505YxMhTrZXKJxC31 uffKpHqY+JHZ0hT4RFTJyMVlF/bo7KN6IHTgmue4rGTNiPVcnpQOLXmrdaBGNU+Ucm qUwkLBdep/DRtNeKq1vmwZSIlkuHnDslRNaM4DxY= Date: Sat, 16 Mar 2019 15:19:12 +0000 From: Jonathan Cameron To: Kangjie Lu Cc: Tomasz Duszynski , pakki001@umn.edu, Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] iio: hmc: fix a potential NULL pointer dereference Message-ID: <20190316151912.4a7ea87d@archlinux> In-Reply-To: <57617810-6F1A-41BF-889C-7A056423C360@umn.edu> References: <20190309051533.14309-1-kjlu@umn.edu> <20190309134208.GA7820@arch> <20190309182950.67a7dd9d@archlinux> <57617810-6F1A-41BF-889C-7A056423C360@umn.edu> 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=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Mar 2019 02:19:25 -0500 Kangjie Lu wrote: > > On Mar 9, 2019, at 12:29 PM, Jonathan Cameron wrote: > >=20 > > On Sat, 9 Mar 2019 14:42:09 +0100 > > Tomasz Duszynski > wrote: > > =20 > >> On Fri, Mar 08, 2019 at 11:15:32PM -0600, Kangjie Lu wrote: =20 > >>> devm_regmap_init_i2c may fail and return NULL. The fix returns > >>> the error when it fails. > >>>=20 > >>> Signed-off-by: Kangjie Lu > >>> --- > >>> drivers/iio/magnetometer/hmc5843_i2c.c | 7 ++++++- > >>> 1 file changed, 6 insertions(+), 1 deletion(-) > >>>=20 > >>> diff --git a/drivers/iio/magnetometer/hmc5843_i2c.c b/drivers/iio/mag= netometer/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_regm= ap_config =3D { > >>> static int hmc5843_i2c_probe(struct i2c_client *cli, > >>> const struct i2c_device_id *id) > >>> { > >>> + struct regmap *devm_regmap =3D devm_regmap_init_i2c(cli, > >>> + &hmc5843_i2c_regmap_config); > >>> + if (IS_ERR(devm_regmap)) > >>> + return PTR_ERR(devm_regmap); =20 > >>=20 > >> This fixes only one part of the problem leaving identical spi issue > >> behind. I guess this check should be part of *common_probe(). =20 > > It could be, but that somewhat hides the error checking. > >=20 > > 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! =20 >=20 > I=E2=80=99ve submitted the patch for spi as well. >=20 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 > >=20 > > Thanks, > >=20 > > Jonathan > > =20 > >> =20 > >>> + > >>> return hmc5843_common_probe(&cli->dev, > >>> - devm_regmap_init_i2c(cli, &hmc5843_i2c_regmap_config), > >>> + devm_regmap, > >>> id->driver_data, id->name); > >>> } > >>>=20 > >>> -- > >>> 2.17.1 =20 >=20