Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp272753ybi; Wed, 29 May 2019 21:07:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqz1YVp3zl6KJUqGOVhvjT4ZoYzTETMTNwaIONHYD0S5bqQ7a6y9Kyq9cRzd3ECA21OY3jgJ X-Received: by 2002:a17:90a:8e86:: with SMTP id f6mr1558942pjo.66.1559189253114; Wed, 29 May 2019 21:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559189253; cv=none; d=google.com; s=arc-20160816; b=hoAdwqkb4mnmwL2ejz02JueKfeME4lIa0rqoHYyllpfxh+AqdxuXTRtpJtoPNIxhqs yhbOiGIOBGVGxDf/8juUZ/lDANh13lXuKmrLiwRM+I7osBljokS3vV66rAZSJtQn7f4h cNGE3Y6Eio5IwNk5GVbGAR55vPTX5U3k513c427fLBN2JxHbmag24RHHKyi7QplBups1 OC7A2tHq/HKD7LjpXY89Bq+AzclxTXJ5Cfz/ulGeEFECfYG+agj54JRho0b38n2QSh2S MZXyHNnf4L3UuRmPZgLFsVbyL6KiL/LH7mZzC6r8N3d6QyEnE8EldnlYDxUnhm9qssaX wGKQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lxyEeXi5m5rzu96tMQgzNCMqTm+F8SdDCkTVHJcFFQ0=; b=GUCTWqrs5aAi7sOycBlHijkZcoAcDjwIxG7hjDAoRbQi3cD/CoLFnIBwDasqeM8Lcn fVZINZ3ciV8tfKrzXQG670lTVDp9H2RA83w1teFqq3OrKMm3SEIH6pLNGmeAtssduvIt GJ3pl7ygTeoqGBbz+wlW40ONX7DWmgA0mROnUiTfmW+FW3+G4/8cj5SsGQwfkyCSdu21 ykqBVBjbWX4i+d93xc/z2oZ+IXhpH7Qlk/VADTvJXPBoC+hwjh0rXE1IrvHt83IHuvrJ 5Ew+mmiAQ/P2Lwe7kJLKk5wbvYixf4Uc+0rPoPvd97iZdDZvpSNtYIc1p/i+Hy/y4fuz psbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=nzdOi70N; 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 bx9si1620493pjb.76.2019.05.29.21.07.16; Wed, 29 May 2019 21:07:33 -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=nzdOi70N; 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 S1726899AbfE3EGE (ORCPT + 99 others); Thu, 30 May 2019 00:06:04 -0400 Received: from mail.kernel.org ([198.145.29.99]:47878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731189AbfE3DRi (ORCPT ); Wed, 29 May 2019 23:17:38 -0400 Received: from localhost (ip67-88-213-2.z213-88-67.customer.algx.net [67.88.213.2]) (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 71CA924664; Thu, 30 May 2019 03:17:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559186257; bh=G7/EF0+sycBI1xObFRMuUqqyLtCEWKWSYGWiHh9zcnk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nzdOi70N7qV+bUkJ9fEScXJpb9O2jM4Topsvp/AibLKBailRLUHmAVRiyMr2bvJX2 /FksVADvZfVkL81fYZ/TORyvEdJSPXuw9bmnGxmD+DmcplqLG5S8T28UwGSwjDVeIC 1VcMr84iB9CkECCC9mbULeSykfz9CI7Zr7Opv8aE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kangjie Lu , Jonathan Cameron , Sasha Levin Subject: [PATCH 4.19 187/276] iio: hmc5843: fix potential NULL pointer dereferences Date: Wed, 29 May 2019 20:05:45 -0700 Message-Id: <20190530030536.909174655@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190530030523.133519668@linuxfoundation.org> References: <20190530030523.133519668@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 536cc27deade8f1ec3c1beefa60d5fbe0f6fcb28 ] devm_regmap_init_i2c may fail and return NULL. The fix returns the error when it fails. Signed-off-by: Kangjie Lu Signed-off-by: Jonathan Cameron Signed-off-by: Sasha Levin --- 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 3de7f4426ac40..86abba5827a25 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 535f03a70d630..79b2b707f90e7 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(spi, &hmc5843_spi_regmap_config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + return hmc5843_common_probe(&spi->dev, - devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config), + regmap, id->driver_data, id->name); } -- 2.20.1