* [PATCH] power: twl4030: fix a missing check of return value
@ 2018-12-20 19:51 Kangjie Lu
2019-01-20 21:38 ` Sebastian Reichel
0 siblings, 1 reply; 2+ messages in thread
From: Kangjie Lu @ 2018-12-20 19:51 UTC (permalink / raw)
To: kjlu; +Cc: pakki001, Sebastian Reichel, linux-pm, linux-kernel
If twl4030_bci_read() fails, the read data in "s" is incorrect,
which is however used in the following execution. The fix checks
the return value of twl4030_bci_read() and returns an error code
upstream upon the failure of twl4030_bci_read().
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
drivers/power/supply/twl4030_charger.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
index 0e202d4273fb..4299873a1118 100644
--- a/drivers/power/supply/twl4030_charger.c
+++ b/drivers/power/supply/twl4030_charger.c
@@ -809,7 +809,9 @@ static int twl4030_bci_get_property(struct power_supply *psy,
is_charging = state & TWL4030_MSTATEC_AC;
if (!is_charging) {
u8 s;
- twl4030_bci_read(TWL4030_BCIMDEN, &s);
+ ret = twl4030_bci_read(TWL4030_BCIMDEN, &s);
+ if (ret < 0)
+ return ret;
if (psy->desc->type == POWER_SUPPLY_TYPE_USB)
is_charging = s & 1;
else
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] power: twl4030: fix a missing check of return value
2018-12-20 19:51 [PATCH] power: twl4030: fix a missing check of return value Kangjie Lu
@ 2019-01-20 21:38 ` Sebastian Reichel
0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2019-01-20 21:38 UTC (permalink / raw)
To: Kangjie Lu; +Cc: pakki001, linux-pm, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1194 bytes --]
Hi,
On Thu, Dec 20, 2018 at 01:51:24PM -0600, Kangjie Lu wrote:
> If twl4030_bci_read() fails, the read data in "s" is incorrect,
> which is however used in the following execution. The fix checks
> the return value of twl4030_bci_read() and returns an error code
> upstream upon the failure of twl4030_bci_read().
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
Thanks, queued to power-supply-next.
-- Sebastian
> drivers/power/supply/twl4030_charger.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/power/supply/twl4030_charger.c b/drivers/power/supply/twl4030_charger.c
> index 0e202d4273fb..4299873a1118 100644
> --- a/drivers/power/supply/twl4030_charger.c
> +++ b/drivers/power/supply/twl4030_charger.c
> @@ -809,7 +809,9 @@ static int twl4030_bci_get_property(struct power_supply *psy,
> is_charging = state & TWL4030_MSTATEC_AC;
> if (!is_charging) {
> u8 s;
> - twl4030_bci_read(TWL4030_BCIMDEN, &s);
> + ret = twl4030_bci_read(TWL4030_BCIMDEN, &s);
> + if (ret < 0)
> + return ret;
> if (psy->desc->type == POWER_SUPPLY_TYPE_USB)
> is_charging = s & 1;
> else
> --
> 2.17.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-21 7:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-20 19:51 [PATCH] power: twl4030: fix a missing check of return value Kangjie Lu
2019-01-20 21:38 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).