From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755172AbbITERq (ORCPT ); Sun, 20 Sep 2015 00:17:46 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:33884 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755077AbbITERm (ORCPT ); Sun, 20 Sep 2015 00:17:42 -0400 Date: Sun, 20 Sep 2015 05:17:39 +0100 From: Lee Jones To: Krzysztof Kozlowski Cc: Javier Martinez Canillas , linux-kernel@vger.kernel.org, Samuel Ortiz Subject: Re: [PATCH] mfd: max77843: Fix max77843_chg_init() return on error Message-ID: <20150920041739.GK3039@x1> References: <1442218991-22197-1-git-send-email-javier@osg.samsung.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 15 Sep 2015, Krzysztof Kozlowski wrote: > 2015-09-14 17:23 GMT+09:00 Javier Martinez Canillas : > > If i2c_new_dummy() fails in max77843_chg_init(), an PTR_ERR(NULL) is > > returned which is 0. So the function was wrongly returning a success > > value instead of an error code. > > > > Fixes: c7f585fe46d8 ("mfd: max77843: Add max77843 MFD driver core driver") > > Signed-off-by: Javier Martinez Canillas > > > > --- > > > > drivers/mfd/max77843.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > Nice catch. I think this should go to stable. I did not try to > reproduce it but looking at the code this should lead to NULL pointer > exceptions on: > 1. first access to max77843->regmap_chg (this won't actually happen > because charger driver was not merged); > 2. first dereference of pointer returned by i2c_get_clientdata() which > will happen on first system suspend or device unbind/removal. > > Reviewed-by: Krzysztof Kozlowski Please re-send this with stable Cc'ed and Krzysztof's RB applied. > > diff --git a/drivers/mfd/max77843.c b/drivers/mfd/max77843.c > > index c52162ea3d0a..586098f1b233 100644 > > --- a/drivers/mfd/max77843.c > > +++ b/drivers/mfd/max77843.c > > @@ -80,7 +80,7 @@ static int max77843_chg_init(struct max77693_dev *max77843) > > if (!max77843->i2c_chg) { > > dev_err(&max77843->i2c->dev, > > "Cannot allocate I2C device for Charger\n"); > > - return PTR_ERR(max77843->i2c_chg); > > + return -ENODEV; > > } > > i2c_set_clientdata(max77843->i2c_chg, max77843); > > > > -- Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog