mirror of
https://github.com/hardkernel/linux.git
synced 2026-03-25 20:10:23 +09:00
octeontx2-pf: Fix a memleak otx2_sq_init
[ Upstream commit b09b58e31b0f43d76f79b9943da3fb7c2843dcbb ]
When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
freed to prevent memleak.
Fixes: c9c12d339d ("octeontx2-pf: Add support for PTP clock")
Signed-off-by: Zhipeng Lu <alexious@zju.edu.cn>
Acked-by: Jiri Pirko <jiri@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
15393c8fd3
commit
c08a3943dc
@@ -856,8 +856,11 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
|
||||
if (pfvf->ptp) {
|
||||
err = qmem_alloc(pfvf->dev, &sq->timestamps, qset->sqe_cnt,
|
||||
sizeof(*sq->timestamps));
|
||||
if (err)
|
||||
if (err) {
|
||||
kfree(sq->sg);
|
||||
sq->sg = NULL;
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
sq->head = 0;
|
||||
@@ -872,7 +875,14 @@ static int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
|
||||
sq->stats.bytes = 0;
|
||||
sq->stats.pkts = 0;
|
||||
|
||||
return pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
|
||||
err = pfvf->hw_ops->sq_aq_init(pfvf, qidx, sqb_aura);
|
||||
if (err) {
|
||||
kfree(sq->sg);
|
||||
sq->sg = NULL;
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user