Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6937589imb; Sat, 9 Mar 2019 10:30:33 -0800 (PST) X-Google-Smtp-Source: APXvYqyV+CCPf8DrvfjXfJyLskyHak7oJTGqL3m4Vwpj+BKN79kwsQlEL5+DLQHM3uDlISDpweEX X-Received: by 2002:a17:902:e711:: with SMTP id co17mr24932080plb.171.1552156233291; Sat, 09 Mar 2019 10:30:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552156233; cv=none; d=google.com; s=arc-20160816; b=XInzcqBbmB9f+rTfA1UCctqjGUkkr1bMGLFYh8CtanZrKEenbOxzNSettuZG3xIpes EtJijmzbJoJUUO92fIKB38Ft0NyL5ENJ8hC3HHIbcAaYv2uCGFDPt2olv87/WJQaIOzg MO7KBMERtHlw60g0iwfK46lfIlGmsY69FPZKwHPxOu0F6jSH47U9QYtEitsnaqkJVcJt P3ND+caWDSiBrx6or/PLoRb9PdOtEyIVwZvrqieTSHSe3uzHgRcVZzyD0ON2glm/Yiy2 kFf6W4WhXvU1u4o6Rk6G6or68M1gzqLZpN8AUp1ZfQjunt/hk9Rf9zhL+Tb3LECyN94F cprw== 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=8YsDeYWl9qo4Bvgxb1nROwemAgIJGrT31zFX6ubOeIU=; b=vQhSFCeLB1xKJJbHy3vjqmb0nQPpbibofWiz3PED/qCCYREhiuSG6qRRVtOxOBN/zN eZMjyk3xp5zqEHq/Kbewv/a2OCz0ewAmRJwTnrKhsHbEyxZ79z5FZIqKKz5B1nTLHzsX orWsbZeYTL9Lsi09G9RXCfnMwjfct+r25kf3HnCrd7o0hEhFjlIg9FJhUipQmllBzrsT JYF7RjF9loFzfKj0pwt0nsSPiBCAzwwW4BAP/u+afIWY36lnS+/lNZdgdNDVgck4qIPk B7B/Ag6b11FOEPmulLchk+P0JOuGzFVX7/h/WsL9qmr0kYlhuHAyMKl4/Qe2oBsZxosw F7Rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=b0qrFU80; 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 s7si881899pfb.153.2019.03.09.10.30.16; Sat, 09 Mar 2019 10:30:33 -0800 (PST) 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=b0qrFU80; 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 S1726400AbfCIS34 (ORCPT + 99 others); Sat, 9 Mar 2019 13:29:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:49310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726351AbfCIS34 (ORCPT ); Sat, 9 Mar 2019 13:29:56 -0500 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 B1C99207E0; Sat, 9 Mar 2019 18:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552156195; bh=RbmhHhdlK8/OIHbMqIAx7cAYULR/XTZGFJ2zrzfBTWk=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=b0qrFU807pCQY0XooX7Fa9eAaAgkx8gtX95vRPrrdJOd2Kt31nepZKMsvRVEVC+O5 GXCBPnYrUsz6KQ7THqnhfZp12ACufiAgir34sQ4BmvzZj8x5fSgJUDt8MrgZXuKxvE n2Fuq61Wc4Bkn+NL1WeZguO89se0kkJvXM1hLmXQ= Date: Sat, 9 Mar 2019 18:29:50 +0000 From: Jonathan Cameron To: Tomasz Duszynski Cc: Kangjie Lu , 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: <20190309182950.67a7dd9d@archlinux> In-Reply-To: <20190309134208.GA7820@arch> References: <20190309051533.14309-1-kjlu@umn.edu> <20190309134208.GA7820@arch> 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 Sat, 9 Mar 2019 14:42:09 +0100 Tomasz Duszynski 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 > > --- > > 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! 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 > >