From: Dan Carpenter Date: Wed, 11 Jun 2014 08:16:51 +0000 (+0300) Subject: drivers: net: davinci_cpdma: double free on error X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2f87208efb5d06003d8f49af06e4501e768c8627;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git drivers: net: davinci_cpdma: double free on error 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 Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 539dbdecd310..4a000f6dd6fc 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -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;