Skip to content

Commit

Permalink
drivers/net/wireless/wl1251: add missing kfree
Browse files Browse the repository at this point in the history
In each case, the kfree already at the end of the function is also needed
in the error case.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
@exists@
local idexpression x;
statement S,S1;
expression E;
identifier fl;
expression *ptr != NULL;
@@

x = \(kmalloc\|kzalloc\|kcalloc\)(...);
...
if (x == NULL) S
<... when != x
     when != if (...) { <+...kfree(x)...+> }
     when any
     when != true x == NULL
x->fl
...>
(
if (x == NULL) S1
|
if (...) { ... when != x
               when forall
(
 return \(0\|<+...x...+>\|ptr\);
|
* return ...;
)
}
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Julia Lawall authored and John W. Linville committed Aug 10, 2011
1 parent bdc71bc commit 059c438
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions drivers/net/wireless/wl1251/acx.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@ int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth)
auth->sleep_auth = sleep_auth;

ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth));
if (ret < 0)
return ret;

out:
kfree(auth);
Expand Down Expand Up @@ -681,10 +679,8 @@ int wl1251_acx_cca_threshold(struct wl1251 *wl)

ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD,
detection, sizeof(*detection));
if (ret < 0) {
if (ret < 0)
wl1251_warning("failed to set cca threshold: %d", ret);
return ret;
}

out:
kfree(detection);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/wl1251/cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable)
if (ret < 0) {
wl1251_error("tx %s cmd for channel %d failed",
enable ? "start" : "stop", channel);
return ret;
goto out;
}

wl1251_debug(DEBUG_BOOT, "tx %s cmd channel %d",
Expand Down

0 comments on commit 059c438

Please sign in to comment.