Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1045278AbdDWM3r (ORCPT ); Sun, 23 Apr 2017 08:29:47 -0400 Received: from m50-132.163.com ([123.125.50.132]:40869 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1045255AbdDWM3h (ORCPT ); Sun, 23 Apr 2017 08:29:37 -0400 From: Pan Bian To: Lee Jones Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] mfd: intel_soc_pmic_core: fix unchecked return value Date: Sun, 23 Apr 2017 20:29:24 +0800 Message-Id: <1492950564-8888-1-git-send-email-bianpan201602@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: DNGowADXbucknvxYHG0mAA--.919S3 X-Coremail-Antispam: 1Uf129KBjvdXoWruFWDXF1fCw15Cr1kXw1rtFb_yoWDArb_W3 yrZr1xZr1rKF1Yq34DurWxAry0kF48W397JFyUtanxC3ZFkF18Zr98ZFnrW348ZrW7ZFyq gr1kZF1xuw13CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IU09YFJUUUUU== X-Originating-IP: [123.118.194.153] X-CM-SenderInfo: held01tdqsiiqwqsqiywtou0bp/1tbiKAbC4FWBW28iMwAAs9 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 965 Lines: 28 From: Pan Bian unction devm_regmap_init_i2c() returns an ERR_PTR on errors, and its return value should be checked before it is dereferenced. However, in function intel_soc_pmic_i2c_probe(), the return value of function devm_regmap_init_i2c() is used without validation. This patch fixes it. Signed-off-by: Pan Bian --- drivers/mfd/intel_soc_pmic_core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mfd/intel_soc_pmic_core.c b/drivers/mfd/intel_soc_pmic_core.c index 12d6ebb4..0498854 100644 --- a/drivers/mfd/intel_soc_pmic_core.c +++ b/drivers/mfd/intel_soc_pmic_core.c @@ -83,6 +83,8 @@ static int intel_soc_pmic_i2c_probe(struct i2c_client *i2c, dev_set_drvdata(dev, pmic); pmic->regmap = devm_regmap_init_i2c(i2c, config->regmap_config); + if (IS_ERR(pmic->regmap)) + return PTR_ERR(pmic->regmap); /* * On some boards the PMIC interrupt may come from a GPIO line. Try to -- 1.9.1