[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20220301174120.0722aed4@kicinski-fedora-PC1C0HJN.hsd1.ca.comcast.net>
Date: Tue, 1 Mar 2022 17:41:20 -0800
From: Jakub Kicinski <kuba@...nel.org>
To: Yeqi Fu <fufuyqqqqqq@...il.com>
Cc: ioana.ciornei@....com, davem@...emloft.net, netdev@...r.kernel.org,
linux-kernel@...r.kernel.org, Yongzhi Liu <lyz_cs@....edu.cn>
Subject: Re: [PATCH v1] dpaa2-switch: fix memory leak of
dpaa2_switch_acl_entry_add
On Tue, 1 Mar 2022 22:15:44 +0800 Yeqi Fu wrote:
> @@ -142,6 +143,7 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block,
> DMA_TO_DEVICE);
> if (err) {
> dev_err(dev, "dpsw_acl_add_entry() failed %d\n", err);
> + kfree(cmd_buff);
> return err;
> }
With more context:
return -EFAULT;
}
err = dpsw_acl_add_entry(ethsw->mc_io, 0, ethsw->dpsw_handle,
filter_block->acl_id, acl_entry_cfg);
dma_unmap_single(dev, acl_entry_cfg->key_iova, sizeof(cmd_buff),
DMA_TO_DEVICE);
if (err) {
dev_err(dev, "dpsw_acl_add_entry() failed %d\n", err);
+ kfree(cmd_buff);
return err;
}
kfree(cmd_buff);
return 0;
}
Here we see unmap is "pulled up" above the error check, same thing can
be done with the kfree(). Otherwise it looks slightly weird - the
buffer unmap and kfree are conceptually part of releasing the buffer,
yet they are split across the paths.
Powered by blists - more mailing lists