* [PATCH net] net: marvell: prestera: Remove unneeded check in prestera_port_create()
@ 2024-08-28 13:26 Aleksandr Mishin
2024-08-28 14:03 ` Maxime Chevallier
0 siblings, 1 reply; 2+ messages in thread
From: Aleksandr Mishin @ 2024-08-28 13:26 UTC (permalink / raw)
To: Vadym Kochan
Cc: Aleksandr Mishin, Taras Chornyi, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Oleksandr Mazur, Serhiy Boiko,
Volodymyr Mytnyk, netdev, linux-kernel, lvc-project
prestera_port_create() calls prestera_rxtx_port_init() and analyze its
return code. prestera_rxtx_port_init() always returns 0, so this check is
unneeded and should be removed.
Remove unneeded check to clean up the code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
---
drivers/net/ethernet/marvell/prestera/prestera_main.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
index 63ae01954dfc..2d4f6d03b729 100644
--- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
+++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
@@ -718,9 +718,7 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
}
}
- err = prestera_rxtx_port_init(port);
- if (err)
- goto err_port_init;
+ prestera_rxtx_port_init(port);
INIT_DELAYED_WORK(&port->cached_hw_stats.caching_dw,
&prestera_port_stats_update);
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: marvell: prestera: Remove unneeded check in prestera_port_create()
2024-08-28 13:26 [PATCH net] net: marvell: prestera: Remove unneeded check in prestera_port_create() Aleksandr Mishin
@ 2024-08-28 14:03 ` Maxime Chevallier
0 siblings, 0 replies; 2+ messages in thread
From: Maxime Chevallier @ 2024-08-28 14:03 UTC (permalink / raw)
To: Aleksandr Mishin
Cc: Vadym Kochan, Taras Chornyi, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Oleksandr Mazur, Serhiy Boiko,
Volodymyr Mytnyk, netdev, linux-kernel, lvc-project
Hello Aleksandr,
On Wed, 28 Aug 2024 16:26:06 +0300
Aleksandr Mishin <amishin@t-argos.ru> wrote:
> prestera_port_create() calls prestera_rxtx_port_init() and analyze its
> return code. prestera_rxtx_port_init() always returns 0, so this check is
> unneeded and should be removed.
>
> Remove unneeded check to clean up the code.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>
> Fixes: 501ef3066c89 ("net: marvell: prestera: Add driver for Prestera family ASIC devices")
> Signed-off-by: Aleksandr Mishin <amishin@t-argos.ru>
> ---
> drivers/net/ethernet/marvell/prestera/prestera_main.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_main.c b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> index 63ae01954dfc..2d4f6d03b729 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_main.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_main.c
> @@ -718,9 +718,7 @@ static int prestera_port_create(struct prestera_switch *sw, u32 id)
> }
> }
>
> - err = prestera_rxtx_port_init(port);
> - if (err)
> - goto err_port_init;
> + prestera_rxtx_port_init(port);
If this function always return 0, you might as well change it to return
void. This would avoid future issues if one were to change
prestera_rxtx_port_init() to acually make it return something. It would
then become obvious that the caller doesn't check the return, whereas
with the current patch, we are simply ignoring it.
I also think you can target that patch to net-next, this isn't fixing
any bug, but rather cleans the code up.
Thanks,
Maxime
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-08-28 14:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-28 13:26 [PATCH net] net: marvell: prestera: Remove unneeded check in prestera_port_create() Aleksandr Mishin
2024-08-28 14:03 ` Maxime Chevallier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox