Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp6505180imb; Fri, 8 Mar 2019 21:19:07 -0800 (PST) X-Google-Smtp-Source: APXvYqztXqpluOV/s/7bj00EpmObNztf7sBlY4ZOQ89v0/Q+b0PaUAfMR4pW9QvjtIHTwTlx9OPm X-Received: by 2002:a63:6c41:: with SMTP id h62mr19724934pgc.371.1552108747632; Fri, 08 Mar 2019 21:19:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1552108747; cv=none; d=google.com; s=arc-20160816; b=P16ZeWsed1vHDp05LVKmbnrKLN4r/koByBuFCiFl8CqFZ6AijidPsemq1ihUmvnNp2 p3yLH3Q4J/cELgbma7d+Gw6Y6MyHOT3JEb+ykd31SYqzc4QDl2kZ5j3tx5u23RmCmHfg JkMjDcD3WCVZb/7JcUTs35ZP61adwW7Z5YDX1+K6nZSMVFzhHGZon6HBbn1Gbfi7qQ0D sXZ0V+HVafu/XW45g48hzuoyqaM+TzTYmfBFAoMIro9zVHVKhLvWZsEvgSaRpXpzJoHS sZwWELxTZdkHyyUHXSa0Dwr9mCe9hyv9wo3zS0/eE19Ep9s8LCv/oqDtLWlbmvqOqMfj QOnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=RVQnwg/PYtBCBexaiykPWmElOOWGcv0g7rMf9iHb8VI=; b=WQyH2pUTVKxLBC/EbCADPZpogHwEaMdVqiVvQ8ja5xvovR+mXjfFA5003IBg5PLGPH CSukrhbS6hnruTx0s6LVWWqLBIEftyze7op10OWr6DVhQmOdxpgLRILrv0SXZMoTMgX/ bNKy0X43MkYoQ5AUX5laMDWs8uSHtXfNJeewRvKYtJnFDQsEr9aFACETk0bKWyx8qDXe tPoG1mymJAWXnOqW1/nLZj9NwINkATJdCfD5vd+bpq1N925H88xxc8edbSUTd5Vd3ZKq 0Bfxp9rd3Mow5A5E4bEtzhIvrU6j20rM/xcO7/wb9topG04FAGnKjny2WJKs5IOhyXl+ 0G5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@umn.edu header.s=google header.b=qpPwEAP5; 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=umn.edu Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 59si8058460plb.405.2019.03.08.21.18.52; Fri, 08 Mar 2019 21:19:07 -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=@umn.edu header.s=google header.b=qpPwEAP5; 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=umn.edu Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726312AbfCIFQI (ORCPT + 99 others); Sat, 9 Mar 2019 00:16:08 -0500 Received: from mta-p7.oit.umn.edu ([134.84.196.207]:48306 "EHLO mta-p7.oit.umn.edu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725613AbfCIFQI (ORCPT ); Sat, 9 Mar 2019 00:16:08 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-p7.oit.umn.edu (Postfix) with ESMTP id E0DECD1B for ; Sat, 9 Mar 2019 05:16:06 +0000 (UTC) X-Virus-Scanned: amavisd-new at umn.edu Received: from mta-p7.oit.umn.edu ([127.0.0.1]) by localhost (mta-p7.oit.umn.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yW9uHTYT8-cJ for ; Fri, 8 Mar 2019 23:16:06 -0600 (CST) Received: from mail-it1-f199.google.com (mail-it1-f199.google.com [209.85.166.199]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mta-p7.oit.umn.edu (Postfix) with ESMTPS id AEA18D44 for ; Fri, 8 Mar 2019 23:16:06 -0600 (CST) Received: by mail-it1-f199.google.com with SMTP id a184so8299491itc.0 for ; Fri, 08 Mar 2019 21:16:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=umn.edu; s=google; h=from:to:cc:subject:date:message-id; bh=RVQnwg/PYtBCBexaiykPWmElOOWGcv0g7rMf9iHb8VI=; b=qpPwEAP5EE9PkZsuh52KgNvt3IldLlkqlJVFgAeo7yWn4BMj/Q88CqSsNDPTUK6B1B 1BQVfwJGCiE0qN1ynQ2MiHCkdj4wfnT5NrpIWTKQ1RTx4b7gP/Xy5Kl12JyznTF66x6T YaShylg0UPS2qNep6mNUCddyJ0276SQ+4C1W6hBNsndVMYvSkRlv1IscR6TZJYqt28q2 axGRi+QpFWPxXTVAscBlBkqZQ3GLIWW/xkovy9tKTrN3ufIfb5VXRwGfXZTeYzvHV25G CuxFn1QCQK+OZOO8lbr/LFVJWy/padGO4uepQUJkGiUa3m2LxXj16gRqWUMuU9N0Bf/3 O7RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RVQnwg/PYtBCBexaiykPWmElOOWGcv0g7rMf9iHb8VI=; b=DbR02LkExxFw/2mmsAymzi40ZFhW8f4WAP3qhLXzd6yUxJzLWCcUjYIOwTVkAy6KEB BaCUqshHJJCrerIJsQPgHJgfhHdr8X/qd8D8tGj5VE9MTAfc5tuN3drw4PeKdwQQMX8K GtwqGiUreQKWQW5JFS776issZpJkiggXaKNznN2WmLLDhzPHUsY4GIWG8qj3AJa6DSfg 6w/W3Si8qVyOzDxNEEsS6nzFv4mXycB6sQ6fD2+VeNfJDwGP3zZQfXO3noYxH4v2x5nQ NC6v3CZlCFDYCxLWBZr5yxP9VqlvwqnLR9aej6ihyRs6ByA+fRRVDflSNfnweS3WeIa8 t6jQ== X-Gm-Message-State: APjAAAX26KdHZNAaTcVUwXUHtWHxJtLU/oY3GVwW//pIdYfEI9B5ViDt LgNM7id7FMmZmE6VthULNrI4guTtmhGO467LBCMySINSvp9lYXbtE+q+8hxJi5tGKoKqTG5tz5Q yHzf5UPbN4ZQu22hm6DwQY7FSeL6u X-Received: by 2002:a02:c6a9:: with SMTP id o9mr12762532jan.70.1552108566289; Fri, 08 Mar 2019 21:16:06 -0800 (PST) X-Received: by 2002:a02:c6a9:: with SMTP id o9mr12762519jan.70.1552108566009; Fri, 08 Mar 2019 21:16:06 -0800 (PST) Received: from bee.dtc.umn.edu (cs-bee-u.cs.umn.edu. [128.101.106.63]) by smtp.gmail.com with ESMTPSA id s10sm4180371ioc.21.2019.03.08.21.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2019 21:16:05 -0800 (PST) From: Kangjie Lu To: kjlu@umn.edu 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: [PATCH] iio: hmc: fix a potential NULL pointer dereference Date: Fri, 8 Mar 2019 23:15:32 -0600 Message-Id: <20190309051533.14309-1-kjlu@umn.edu> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); + 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