Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6763237imb; Sat, 9 Mar 2019 05:44:11 -0800 (PST) X-Google-Smtp-Source: APXvYqz7QOrTci9nOMmF2st3GitXxWka6ALlZkwZDSfaUBRh8rLMnnzGiMygY/29FaHG7xi1n9Ee X-Received: by 2002:a17:902:be15:: with SMTP id r21mr23673446pls.143.1552139051132; Sat, 09 Mar 2019 05:44:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552139051; cv=none; d=google.com; s=arc-20160816; b=MU6MfqaLHzM5pF+1P0psMGSHigIzLfDtomfmYOqJo0e/B9eXZd6wV/iZ4a5IpsELmf 5fqY/PEDj/jcAwJmZ0hNgAYNmPhoU5gV6ldSF4kN5Q0JlmcYx/0/+u+eh71Jr7PT0u+A C6K7Sh5wjyZ3BqlV6CCcFYbYYkUlYhzDzOLwWMxswzHA1Ic2Z3r0J8J3rl2XiDkL52ff OSUSVWi0KgG9VoV48+Iuy4cejZJaSNdhw1TTMezBT6BGfIFSMhILOwVJyXi3spzF/+2Z 0U1xQUKgjZPxwlLjCuMSfI+0Qhlmu8bVvCb3IGO7g1f74jl0HrXONxacF2uO/QMWGx49 xqzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=oKD3oXM7E538cMAEIk9ppvfbsy+jgNinUkCJBtcouy8=; b=FIs5HXtYQklnHnlMdIDFkwBP/G9Evxpfpi3x93w8SIbt1Stl9WFslgGjalIMU3KIOy vIHdxZ0FUCaZtJcX11byCn4acDvp9fei+1yIXt0sv+W5aJS5N9d1cYoKM3RtAix3So9P junZCXJrKmNK1CtgfULRN3z3hllc4/keNsdmUF4cfnEOv/UIxuTXFeiXgxNaVjQcLjtF iRQOJejk+0+UK722PP0fjJAQ/sU+7Vwl1JxP84qufF+pNoPLW1nmyn1f+mp75FWtl9Pb gxvKtGdU4u5BUmW4YeucDw2u8cQPps1lJJZFI7ZEaeTxjpF0kPn+PqetSurPFzlElA78 Fzsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="VGGQ/n9i"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si560352pll.74.2019.03.09.05.43.25; Sat, 09 Mar 2019 05:44:11 -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=@gmail.com header.s=20161025 header.b="VGGQ/n9i"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726372AbfCINmh (ORCPT + 99 others); Sat, 9 Mar 2019 08:42:37 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44284 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726233AbfCINmh (ORCPT ); Sat, 9 Mar 2019 08:42:37 -0500 Received: by mail-lf1-f66.google.com with SMTP id u9so317391lfe.11; Sat, 09 Mar 2019 05:42:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=oKD3oXM7E538cMAEIk9ppvfbsy+jgNinUkCJBtcouy8=; b=VGGQ/n9iiSneCxhRcuZAfxYmhflOWSoyP486lSK8N/ZxYuTdivrGnIFEb4WOuX/AXe XOzYrtTb6Jb52R4sjqEooPlGKdB+mFhtqIr3Wx0LG0dDod+HZ8Y7K5BPPfd4qFCAtLAp tO2NQFC9vEbUYnqwe1GjGyNBMl0eGZvMayqgwpmYBcODMSn0xdsPXLGCM3XHMphen5Wr w/AJbahfe8lA6Ep6Er0738le6wc93za1cXfvKaJKpcgG2FoatUexy9D9euNzGIrICSPn m+zEk5V2l5jpv/4nXJ1Uxc3F8bggyUNr9XVPOVly2AyJsbITAsATLgCe2RqNKAU11Jus G1Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=oKD3oXM7E538cMAEIk9ppvfbsy+jgNinUkCJBtcouy8=; b=b48nj+L6Rdm0djFgZGFRKwQ+2U+ceUxRiHZNMAm33IXq87ilFa3NCsl73ua8pmhMbk MP5RMPIOwRDViygTSM5vWietTeLbr6F/6SgfveHwtl1niChRRSA4ARaon2fdSOTf9xH6 zeTXitnfs9cKYsDrf9YWF4D8rvBzktzrP2EnvumfiREjBbIYLC8rzElyvEV8gMuQQ6WI L+JUlv1JMP5ZQfqax2qOBPmN/i9GTEj2XrliMYUWrkthoDAP3wsR5K4EBkXomTlYutjO 9UEDqxyI57CEFJnFzm1cIPpDEZlOUQ6T/ZGhd8o/ocpb1qke3608z/1VHALRLqa5IDBF eAAQ== X-Gm-Message-State: APjAAAUG+GqjbJrzqw3jROO8gJoiwkOzzJPGPEFfpoNZNZXmMUs2K78c Dcvji683REiLumwdojErEUE= X-Received: by 2002:ac2:5386:: with SMTP id g6mr4640585lfh.88.1552138955060; Sat, 09 Mar 2019 05:42:35 -0800 (PST) Received: from localhost (89-64-59-159.dynamic.chello.pl. [89.64.59.159]) by smtp.gmail.com with ESMTPSA id f1sm123590lfc.48.2019.03.09.05.42.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Mar 2019 05:42:34 -0800 (PST) Date: Sat, 9 Mar 2019 14:42:09 +0100 From: Tomasz Duszynski To: Kangjie Lu Cc: pakki001@umn.edu, Jonathan Cameron , 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: <20190309134208.GA7820@arch> References: <20190309051533.14309-1-kjlu@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20190309051533.14309-1-kjlu@umn.edu> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). > + > 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 >