Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf()
@ 2026-09-02  9:10 Muhammad Falak R Wani
  2026-09-03  9:10 ` sashiko-bot
  2026-09-04 23:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Muhammad Falak R Wani @ 2026-09-02  9:10 UTC (permalink / raw)
  To: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
	edumazet, kuba, pabeni
  Cc: linux-hyperv, netdev, linux-kernel, bpf, Hamza Mahfooz

mana_bpf() has a trailing 'return ret;' after a switch statement whose
every case (XDP_SETUP_PROG and default) already returns unconditionally.
The statement is therefore unreachable and 'ret' is never used.

Remove both. No functional change intended.

Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
Reviewed-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
---
v2:
  - reword the commit message: drop the claim that an uninitialized value
    could be returned; every switch case returns unconditionally, so the
    statement is simply unreachable. Describe it as a pure cleanup.
  - drop the Fixes: tag offered during v1 review, per the guidance that
    net-next changes should not carry Fixes: tags.
  - no code changes.
v1: https://lore.kernel.org/netdev/DKWZHHOFA1F3.1EL2DMFNGMP0Y@gmail.com/

 drivers/net/ethernet/microsoft/mana/mana_bpf.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
index 53308e139cbe9..70bb8c9dc3413 100644
--- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
@@ -253,7 +253,6 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
 int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 {
 	struct netlink_ext_ack *extack = bpf->extack;
-	int ret;
 
 	switch (bpf->command) {
 	case XDP_SETUP_PROG:
@@ -262,6 +261,4 @@ int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
 	default:
 		return -EOPNOTSUPP;
 	}
-
-	return ret;
 }
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf()
  2026-09-02  9:10 [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf() Muhammad Falak R Wani
@ 2026-09-03  9:10 ` sashiko-bot
  2026-09-04 23:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-09-03  9:10 UTC (permalink / raw)
  To: Muhammad Falak R Wani; +Cc: bpf, linux-hyperv

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Failure to restore `apc->bpf_prog` on error path causes Use-After-Free.
--

commit 26086af444af1d715f516a007146a7dd00ce97c6
Author: Muhammad Falak R Wani <falakreyaz@gmail.com>

net: mana: remove unreachable dead code in mana_bpf()

This commit cleans up mana_bpf() by removing an unreachable return statement
after a switch statement that already unconditionally returns.

Link: https://lore.kernel.org/netdev/DKWZHHOFA1F3.1EL2DMFNGMP0Y@gmail.com/

> diff --git a/drivers/net/ethernet/microsoft/mana/mana_bpf.c b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> index 53308e139cbe9..70bb8c9dc3413 100644
> --- a/drivers/net/ethernet/microsoft/mana/mana_bpf.c
> +++ b/drivers/net/ethernet/microsoft/mana/mana_bpf.c
[ ... ]

This is a pre-existing issue, but while reviewing this patch I noticed a
potential problem in the adjacent mana_xdp_set() function when it handles
allocation failures:

drivers/net/ethernet/microsoft/mana/mana_bpf.c:mana_xdp_set() {
        ...
        apc->bpf_prog = prog;

        if (apc->port_is_up) {
                ...
                err = mana_pre_alloc_rxbufs(apc, ndev->mtu, apc->num_queues);
                if (err) {
                        NL_SET_ERR_MSG_MOD(extack,
                                           "XDP: Insufficient memory for tx/rx re-config");
                        return err;
                }
        ...
}

[Severity: High]
Does this error path leave a dangling pointer in apc->bpf_prog?

It appears that if mana_pre_alloc_rxbufs() fails, the function returns
immediately without restoring apc->bpf_prog = old_prog. The generic XDP caller
will see the failure, assume the driver rejected the program, and drop its BPF
program reference.

Could this leave a freed pointer in apc->bpf_prog that might be dereferenced
when the interface is later restarted or accessed?

> @@ -253,7 +253,6 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
>  int mana_bpf(struct net_device *ndev, struct netdev_bpf *bpf)
>  {
>  	struct netlink_ext_ack *extack = bpf->extack;
> -	int ret;
>  
>  	switch (bpf->command) {
>  	case XDP_SETUP_PROG:
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/3d8b67307df6fefdc18743274cef3de4fca0e7de.1788339612.git.falakreyaz@gmail.com?part=1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf()
  2026-09-02  9:10 [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf() Muhammad Falak R Wani
  2026-09-03  9:10 ` sashiko-bot
@ 2026-09-04 23:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-04 23:10 UTC (permalink / raw)
  To: Muhammad Falak R Wani
  Cc: kys, haiyangz, wei.liu, decui, longli, andrew+netdev, davem,
	edumazet, kuba, pabeni, linux-hyperv, netdev, linux-kernel, bpf,
	hamzamahfooz

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Wed,  2 Sep 2026 14:40:10 +0530 you wrote:
> mana_bpf() has a trailing 'return ret;' after a switch statement whose
> every case (XDP_SETUP_PROG and default) already returns unconditionally.
> The statement is therefore unreachable and 'ret' is never used.
> 
> Remove both. No functional change intended.
> 
> Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
> Reviewed-by: Hamza Mahfooz <hamzamahfooz@linux.microsoft.com>
> 
> [...]

Here is the summary with links:
  - [net-next,v2] net: mana: remove unreachable dead code in mana_bpf()
    https://git.kernel.org/netdev/net-next/c/8d5f1bda7e8b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-09-04 23:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02  9:10 [PATCH net-next v2] net: mana: remove unreachable dead code in mana_bpf() Muhammad Falak R Wani
2026-09-03  9:10 ` sashiko-bot
2026-09-04 23:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox