Skip to content

Commit

Permalink
octeontx2-pf: Fix a memleak otx2_sq_init
Browse files Browse the repository at this point in the history
[ Upstream commit b09b58e ]

When qmem_alloc and pfvf->hw_ops->sq_aq_init fails, sq->sg should be
freed to prevent memleak.

Fixes: c9c12d3 ("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>
  • Loading branch information
AlexiousLu authored and gregkh committed Feb 16, 2024
1 parent c267f63 commit 1731cb9
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,11 @@ int otx2_sq_init(struct otx2_nic *pfvf, u16 qidx, u16 sqb_aura)
if (pfvf->ptp && qidx < pfvf->hw.tx_queues) {
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;
Expand All @@ -968,7 +971,14 @@ 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;

}

Expand Down

0 comments on commit 1731cb9

Please sign in to comment.