All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krzysztof Kozlowski <k.kozlowski@samsung.com>
To: Arnd Bergmann <arnd@arndb.de>, Mark Brown <broonie@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org,
	Sangbeom Kim <sbkim73@samsung.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	linux-kernel@vger.kernel.org, linux-samsung-soc@vger.kernel.org
Subject: Re: [PATCH] regulator: s5m8767: fix get_register() error handling
Date: Wed, 17 Feb 2016 09:00:36 +0900	[thread overview]
Message-ID: <56C3B824.9010808@samsung.com> (raw)
In-Reply-To: <1455634402-1997203-1-git-send-email-arnd@arndb.de>

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 <arnd@arndb.de>
> 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 <k.kozlowski@samsung.com>

Best regards,
Krzysztof

WARNING: multiple messages have this Message-ID (diff)
From: k.kozlowski@samsung.com (Krzysztof Kozlowski)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] regulator: s5m8767: fix get_register() error handling
Date: Wed, 17 Feb 2016 09:00:36 +0900	[thread overview]
Message-ID: <56C3B824.9010808@samsung.com> (raw)
In-Reply-To: <1455634402-1997203-1-git-send-email-arnd@arndb.de>

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 <arnd@arndb.de>
> 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 <k.kozlowski@samsung.com>

Best regards,
Krzysztof

  reply	other threads:[~2016-02-17  0:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-16 14:53 [PATCH] regulator: s5m8767: fix get_register() error handling Arnd Bergmann
2016-02-16 14:53 ` Arnd Bergmann
2016-02-17  0:00 ` Krzysztof Kozlowski [this message]
2016-02-17  0:00   ` Krzysztof Kozlowski
2016-02-17 13:04 ` Applied "regulator: s5m8767: fix get_register() error handling" to the regulator tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56C3B824.9010808@samsung.com \
    --to=k.kozlowski@samsung.com \
    --cc=arnd@arndb.de \
    --cc=broonie@kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=sbkim73@samsung.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.