From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933434AbcBQAA5 (ORCPT ); Tue, 16 Feb 2016 19:00:57 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:36707 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933243AbcBQAAo (ORCPT ); Tue, 16 Feb 2016 19:00:44 -0500 X-AuditID: cbfec7f4-f79026d00000418a-32-56c3b829301c Subject: Re: [PATCH] regulator: s5m8767: fix get_register() error handling To: Arnd Bergmann , Mark Brown References: <1455634402-1997203-1-git-send-email-arnd@arndb.de> Cc: linux-arm-kernel@lists.infradead.org, Sangbeom Kim , Liam Girdwood , linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org From: Krzysztof Kozlowski Message-id: <56C3B824.9010808@samsung.com> Date: Wed, 17 Feb 2016 09:00:36 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1 MIME-version: 1.0 In-reply-to: <1455634402-1997203-1-git-send-email-arnd@arndb.de> Content-type: text/plain; charset=windows-1252 Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrALMWRmVeSWpSXmKPExsVy+t/xa7qaOw6HGXxcIWvxd9IxdoupD5+w Wbx+YWjx7UoHk8Wmx9dYLS7vmsNmMeP8PiaLiyu+MDlwePz+NYnRY+esu+wem1Z1snlsXlLv 0bdlFaPH501yAWxRXDYpqTmZZalF+nYJXBlvX29iKXjCXdHw8yZjA+MPzi5GTg4JAROJxRe6 WCBsMYkL99azdTFycQgJLGWUuPH6L1hCSOApo8TVU/kgtrCAl0TX9KusILaIgJPEpaNXoWrs JQ4dbmECaWYW2MYo8enXW2aQBJuAscTm5UuApnJw8ApoSSyaXAxisgioSpxoUwCpEBWIkDjc 2cUOYvMKCEr8mHwPbCSngIPE9CMNjCDlzAJ6EvcvaoGEmQXkJTavecs8gVFgFpKOWQhVs5BU LWBkXsUomlqaXFCclJ5rqFecmFtcmpeul5yfu4kREu5fdjAuPmZ1iFGAg1GJhzcg43CYEGti WXFl7iFGCQ5mJRFexelAId6UxMqq1KL8+KLSnNTiQ4zSHCxK4rxzd70PERJITyxJzU5NLUgt gskycXBKNTAucVT9ZhIqVKGmLbeBb2tZmlfejqIryQYSHxZ+emP+22HtZGOxjB9fT9wIPnpR tOq3/IEtJ9zWHxGxsriiIRN0i7/NdGfqC99fQnfUkt8zzZmyUW194/8p3ZKd70SKzj1S2vLL kjPbQ06wxPmJT3/q7UKJEy+a18SF8HSk1PEKnJ0r4dTA2KvEUpyRaKjFXFScCABI1OvkcwIA AA== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16.02.2016 23:53, Arnd Bergmann wrote: > The s5m8767_pmic_probe() function calls s5m8767_get_register() to > read data without checking the return code, which produces a compile-time > warning when that data is accessed: > > drivers/regulator/s5m8767.c: In function 's5m8767_pmic_probe': > drivers/regulator/s5m8767.c:924:7: error: 'enable_reg' may be used uninitialized in this function [-Werror=maybe-uninitialized] > drivers/regulator/s5m8767.c:944:30: error: 'enable_val' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > This changes the s5m8767_get_register() function to return a -EINVAL > not just for an invalid register number but also for an invalid > regulator number, as both would result in returning uninitialized > data. The s5m8767_pmic_probe() function is then changed accordingly > to fail on a read error, as all the other callers of s5m8767_get_register() > already do. > > In practice this probably cannot happen, as we don't call > s5m8767_get_register() with invalid arguments, but the gcc > warning seems valid in principle, in terms writing safe > error checking. > > Signed-off-by: Arnd Bergmann > Fixes: 9c4c60554acf ("regulator: s5m8767: Convert to use regulator_[enable|disable|is_enabled]_regmap") > --- > drivers/regulator/s5m8767.c | 13 +++++++++---- > 1 file changed, 9 insertions(+), 4 deletions(-) > Reviewed-by: Krzysztof Kozlowski Best regards, Krzysztof