diff options
author | Peter Senna Tschudin <peter.senna@gmail.com> | 2012-09-12 11:06:43 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-09-12 12:43:45 -0400 |
commit | 2e464f00687931eeeab95c90e3796609d0c8ce4c (patch) | |
tree | 07323d6e4281b6208c8004cb0ba8a37f26ea3ff4 | |
parent | e66fc1fba248738d32f3b64508f9ef1176d9e767 (diff) |
drivers/staging/rtl8192u/r8192U_core.c: Remove useless kfree
Remove useless kfree() and clean up code related to the removal.
The semantic patch that finds this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@r exists@
position p1,p2;
expression x;
@@
if (x@p1 == NULL) { ... kfree@p2(x); ... return ...; }
@unchanged exists@
position r.p1,r.p2;
expression e <= r.x,x,e1;
iterator I;
statement S;
@@
if (x@p1 == NULL) { ... when != I(x,...) S
when != e = e1
when != e += e1
when != e -= e1
when != ++e
when != --e
when != e++
when != e--
when != &e
kfree@p2(x); ... return ...; }
@ok depends on unchanged exists@
position any r.p1;
position r.p2;
expression x;
@@
... when != true x@p1 == NULL
kfree@p2(x);
@depends on !ok && unchanged@
position r.p2;
expression x;
@@
*kfree@p2(x);
// </smpl>
Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/rtl8192u/r8192U_core.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index 5c132ac7647d..5a2fab9fa772 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c | |||
@@ -2232,24 +2232,15 @@ short rtl8192_usb_initendpoints(struct net_device *dev) | |||
2232 | memset(priv->rx_urb, 0, sizeof(struct urb*) * MAX_RX_URB); | 2232 | memset(priv->rx_urb, 0, sizeof(struct urb*) * MAX_RX_URB); |
2233 | priv->pp_rxskb = kcalloc(MAX_RX_URB, sizeof(struct sk_buff *), | 2233 | priv->pp_rxskb = kcalloc(MAX_RX_URB, sizeof(struct sk_buff *), |
2234 | GFP_KERNEL); | 2234 | GFP_KERNEL); |
2235 | if (priv->pp_rxskb == NULL) | 2235 | if (!priv->pp_rxskb) { |
2236 | goto destroy; | 2236 | kfree(priv->rx_urb); |
2237 | |||
2238 | goto _middle; | ||
2239 | |||
2240 | |||
2241 | destroy: | ||
2242 | kfree(priv->pp_rxskb); | ||
2243 | kfree(priv->rx_urb); | ||
2244 | |||
2245 | priv->pp_rxskb = NULL; | ||
2246 | priv->rx_urb = NULL; | ||
2247 | |||
2248 | DMESGE("Endpoint Alloc Failure"); | ||
2249 | return -ENOMEM; | ||
2250 | 2237 | ||
2238 | priv->pp_rxskb = NULL; | ||
2239 | priv->rx_urb = NULL; | ||
2251 | 2240 | ||
2252 | _middle: | 2241 | DMESGE("Endpoint Alloc Failure"); |
2242 | return -ENOMEM; | ||
2243 | } | ||
2253 | 2244 | ||
2254 | printk("End of initendpoints\n"); | 2245 | printk("End of initendpoints\n"); |
2255 | return 0; | 2246 | return 0; |