diff mbox series

[next,1/2] octeontx2-pf: fix netdev memory leak in rvu_rep_create()

Message ID 20241216070516.4036749-1-harshit.m.mogalapalli@oracle.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [next,1/2] octeontx2-pf: fix netdev memory leak in rvu_rep_create() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 10 of 10 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-16--09-00 (tests: 795)

Commit Message

Harshit Mogalapalli Dec. 16, 2024, 7:05 a.m. UTC
When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
incomplete iteration before going to "exit:" label.

Fixes: 3937b7308d4f ("octeontx2-pf: Create representor netdev")
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
---
This is found by Smatch, based on static analysis, only compile tested.
---
 drivers/net/ethernet/marvell/octeontx2/nic/rep.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Przemek Kitszel Dec. 16, 2024, 8:09 a.m. UTC | #1
On 12/16/24 08:05, Harshit Mogalapalli wrote:
> When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
> incomplete iteration before going to "exit:" label.
> 
> Fixes: 3937b7308d4f ("octeontx2-pf: Create representor netdev")

I would say that you are fixing:
Fixes: 9ed0343f561e ("octeontx2-pf: Add devlink port support")

this is also a -net material

code is fine otherwise, so:
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>

> Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
> ---
> This is found by Smatch, based on static analysis, only compile tested.
> ---
>   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);
Harshit Mogalapalli Dec. 16, 2024, 9:05 a.m. UTC | #2
Hi,

On 16/12/24 13:39, Przemek Kitszel wrote:
> On 12/16/24 08:05, Harshit Mogalapalli wrote:
>> When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
>> incomplete iteration before going to "exit:" label.
>>
>> Fixes: 3937b7308d4f ("octeontx2-pf: Create representor netdev")
> 

Thanks for the review.
> I would say that you are fixing:
> Fixes: 9ed0343f561e ("octeontx2-pf: Add devlink port support")
> 
Oh right, thank you for catching that. Will fix in V2.
> this is also a -net material

So while sending a V2 I will include [PATCH net-next], that sounds good ?

Thanks,
Harshit
Przemek Kitszel Dec. 16, 2024, 9:15 a.m. UTC | #3
On 12/16/24 10:05, Harshit Mogalapalli wrote:
> Hi,
> 
> On 16/12/24 13:39, Przemek Kitszel wrote:
>> On 12/16/24 08:05, Harshit Mogalapalli wrote:
>>> When rvu_rep_devlink_port_register() fails, free_netdev(ndev) for this
>>> incomplete iteration before going to "exit:" label.
>>>
>>> Fixes: 3937b7308d4f ("octeontx2-pf: Create representor netdev")
>>
> 
> Thanks for the review.
>> I would say that you are fixing:
>> Fixes: 9ed0343f561e ("octeontx2-pf: Add devlink port support")
>>
> Oh right, thank you for catching that. Will fix in V2.
>> this is also a -net material
> 
> So while sending a V2 I will include [PATCH net-next], that sounds good ?

Just [PATCH net v2].

Please add my Reviewed-by tags to both patches.
Please wait also one day, to don't send same series twice within 24h.

> 
> Thanks,
> Harshit
diff mbox series

Patch

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);