Skip to contentSkip to conversation

drivers: net: davinci_cpdma: drop devm_kfree of devm_kzalloc'd data

PATCH In review Himangi Saraogi 2 participants 2 messages Aug 10, 2014

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drivers: net: davinci_cpdma: drop devm_kfree of devm_kzalloc'd data

devm_kfree should not have to be explicitly used.

The Coccinelle semantic patch that fixes this problem is as follows:

// <smpl>
@@
expression x,d;
@@

x = devm_kzalloc(...)
...
?-devm_kfree(d,x);
// </smpl>

---
 drivers/net/ethernet/ti/davinci_cpdma.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/ti/davinci_cpdma.c +0 -1
index 4a000f6..af673f5 100644
@@ -512,7 +512,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
 	spin_lock_irqsave(&ctlr->lock, flags);
 	if (ctlr->channels[chan_num]) {
 		spin_unlock_irqrestore(&ctlr->lock, flags);
-		devm_kfree(ctlr->dev, chan);
 		return ERR_PTR(-EBUSY);
 	}
 
Signature · 1 line
1.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Himangi Saraogi

devm_kfree should not have to be explicitly used.

The Coccinelle semantic patch that fixes this problem is as follows:

// <smpl>
@@
expression x,d;
@@

Quoted 7 lines

x = devm_kzalloc(...)
...
?-devm_kfree(d,x);
// </smpl>

However, you need to resend this patch after 3.17-rc1 has been released and the net-next branch was opened again.

Thanks,
Daniel

Quoted 17 lines
---
 drivers/net/ethernet/ti/davinci_cpdma.c | 1 -
 1 file changed, 1 deletion(-)
drivers/net/ethernet/ti/davinci_cpdma.c +0 -1
index 4a000f6..af673f5 100644
@@ -512,7 +512,6 @@ struct cpdma_chan *cpdma_chan_create(struct cpdma_ctlr *ctlr, int chan_num,
 	spin_lock_irqsave(&ctlr->lock, flags);
 	if (ctlr->channels[chan_num]) {
 		spin_unlock_irqrestore(&ctlr->lock, flags);
-		devm_kfree(ctlr->dev, chan);
 		return ERR_PTR(-EBUSY);
 	}