drivers: net: davinci_cpdma: double free on error
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 11 Jun 2014 08:16:51 +0000 (11:16 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 11 Jun 2014 22:39:19 +0000 (15:39 -0700)
We recently change the kzalloc() to devm_kzalloc() so freeing "ctlr"
here could lead to a double free.

Fixes: e194312854ed ('drivers: net: davinci_cpdma: Convert kzalloc() to devm_kzalloc().')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/ti/davinci_cpdma.c

index 539dbdecd310e870ea98ae05bcd989b4aebc5dfb..4a000f6dd6fc35d274f585a8536bd325666fdcb2 100644 (file)
@@ -285,10 +285,8 @@ struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params)
                                            ctlr->params.desc_hw_addr,
                                            ctlr->params.desc_mem_size,
                                            ctlr->params.desc_align);
-       if (!ctlr->pool) {
-               kfree(ctlr);
+       if (!ctlr->pool)
                return NULL;
-       }
 
        if (WARN_ON(ctlr->num_chan > CPDMA_MAX_CHANNELS))
                ctlr->num_chan = CPDMA_MAX_CHANNELS;