From: Christophe Jaillet Date: Sun, 19 Feb 2017 09:19:57 +0000 (+0100) Subject: net: mvpp2: Fix a memory leak in error handling path X-Git-Tag: v4.14-rc1~1463^2~27 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=177c8d1c96eb9851210313922a12ae8b0b63d8c0;p=platform%2Fkernel%2Flinux-rpi.git net: mvpp2: Fix a memory leak in error handling path if 'devm_kzalloc()' fails, we should release resources allocated so far, just as done a few lines below. Signed-off-by: Christophe JAILLET Signed-off-by: David S. Miller --- diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index c2fd7c3..c486320 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -5971,8 +5971,10 @@ static int mvpp2_port_init(struct mvpp2_port *port) struct mvpp2_tx_queue *txq; txq = devm_kzalloc(dev, sizeof(*txq), GFP_KERNEL); - if (!txq) - return -ENOMEM; + if (!txq) { + err = -ENOMEM; + goto err_free_percpu; + } txq->pcpu = alloc_percpu(struct mvpp2_txq_pcpu); if (!txq->pcpu) {