diff mbox

[2/2] wl12xx: Fix validation of pm_runtime_get_sync return value

Message ID 1312269858-30434-2-git-send-email-ido@wizery.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Ido Yariv Aug. 2, 2011, 7:24 a.m. UTC
wl1271_sdio_power_on checks if the return value of pm_runtime_get_sync
is non-zero, and if so bails out.
However, pm_runtime_get_sync can return a positive number which does not
suggest an error has occurred. This is problematic for two reasons:

1. The function will needlessly bail out without decrementing back the
   runtime PM reference counter.
2. wl1271_power_on only checks if wl1271_power_on return value is
   negative. This means that wl1271_power_on will continue even if
   wl1271_sdio_power_on bailed out. As a result, sdio transactions will
   be initiated without properly enabling the sdio function and claiming
   the host. This could even lead to a kernel panic.

Fix this by only checking that the return value of pm_runtime_get_sync
is non-negative.

Signed-off-by: Ido Yariv <ido@wizery.com>
---
 drivers/net/wireless/wl12xx/sdio.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Luciano Coelho Aug. 11, 2011, 5:57 a.m. UTC | #1
On Tue, 2011-08-02 at 10:24 +0300, Ido Yariv wrote: 
> wl1271_sdio_power_on checks if the return value of pm_runtime_get_sync
> is non-zero, and if so bails out.
> However, pm_runtime_get_sync can return a positive number which does not
> suggest an error has occurred. This is problematic for two reasons:
> 
> 1. The function will needlessly bail out without decrementing back the
>    runtime PM reference counter.
> 2. wl1271_power_on only checks if wl1271_power_on return value is
>    negative. This means that wl1271_power_on will continue even if
>    wl1271_sdio_power_on bailed out. As a result, sdio transactions will
>    be initiated without properly enabling the sdio function and claiming
>    the host. This could even lead to a kernel panic.
> 
> Fix this by only checking that the return value of pm_runtime_get_sync
> is non-negative.
> 
> Signed-off-by: Ido Yariv <ido@wizery.com>
> ---

Acked-by: Luciano Coelho <coelho@ti.com>
diff mbox

Patch

diff --git a/drivers/net/wireless/wl12xx/sdio.c b/drivers/net/wireless/wl12xx/sdio.c
index 5cf18c2..fb1fd5a 100644
--- a/drivers/net/wireless/wl12xx/sdio.c
+++ b/drivers/net/wireless/wl12xx/sdio.c
@@ -164,7 +164,7 @@  static int wl1271_sdio_power_on(struct wl1271 *wl)
 	/* If enabled, tell runtime PM not to power off the card */
 	if (pm_runtime_enabled(&func->dev)) {
 		ret = pm_runtime_get_sync(&func->dev);
-		if (ret)
+		if (ret < 0)
 			goto out;
 	} else {
 		/* Runtime PM is disabled: power up the card manually */