RE: [EXTERNAL] [PATCH net v2 1/2] octeontx2-pf: fix netdev memory leak in rvu_rep_create()

Geethasowjanya Akula
2024-12-18T06:03:46Z

>-----Original Message-----
>From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
>Sent: Tuesday, December 17, 2024 10:53 AM
>To: Sunil Kovvuri Goutham <sgoutham@marvell.com>; Geethasowjanya Akula
><gakula@marvell.com>; Subbaraya Sundeep Bhatta <sbhatta@marvell.com>;
>Hariprasad Kelam <hkelam@marvell.com>; Bharat Bhushan
><bbhushan2@marvell.com>; Andrew Lunn <andrew+netdev@lunn.ch>; David
>S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>;
>Jakub Kicinski <kuba@kernel.org>; Paolo Abeni <pabeni@redhat.com>; Simon
>Horman <horms@kernel.org>; netdev@vger.kernel.org; linux-
>kernel@vger.kernel.org
>Cc: dan.carpenter@linaro.org; kernel-janitors@vger.kernel.org;
>error27@gmail.com; harshit.m.mogalapalli@oracle.com; Przemek Kitszel
><przemyslaw.kitszel@intel.com>
>Subject: [EXTERNAL] [PATCH net v2 1/2] octeontx2-pf: fix netdev memory leak
>in rvu_rep_create()
>
>When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
>incomplete iteration before going to "exit:" label.
>
>Fixes: 9ed0343f561e ("octeontx2-pf: Add devlink port support")
>Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
>Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
>---
>v1-->v2: Change the Fixes tag to the correct one as pointed out by
>v1-->Przemek
>---
> drivers/net/ethernet/marvell/octeontx2/nic/rep.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
>b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
>index 232b10740c13..9e3fcbae5dee 100644
>--- a/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
>+++ b/drivers/net/ethernet/marvell/octeontx2/nic/rep.c
>@@ -680,8 +680,10 @@ int rvu_rep_create(struct otx2_nic *priv, struct
>netlink_ext_ack *extack)
> ndev->features |= ndev->hw_features;
> eth_hw_addr_random(ndev);
> err = rvu_rep_devlink_port_register(rep);
>- if (err)
>+ if (err) {
>+ free_netdev(ndev);
> goto exit;
>+ }
>
> SET_NETDEV_DEVLINK_PORT(ndev, &rep->dl_port);
> err = register_netdev(ndev);
>--
>2.46.0
Ack. Thanks for the fix.