* [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom
@ 2023-02-06 15:48 Simon Horman
2023-02-07 10:09 ` Leon Romanovsky
2023-02-08 4:30 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Simon Horman @ 2023-02-06 15:48 UTC (permalink / raw)
To: David Miller, Jakub Kicinski, Paolo Abeni
Cc: netdev, oss-drivers, James Hershaw, Louis Peens, Simon Horman
From: James Hershaw <james.hershaw@corigine.com>
Move the nfp_net_get_port_mac_by_hwinfo() check to ahead in the
get/set_eeprom() functions to in order to check for a VF netdev, which
this function does not support.
It is debatable if this is a fix or an enhancement, and we have chosen
to go for the latter. It does address a problem introduced by
commit 74b4f1739d4e ("nfp: flower: change get/set_eeprom logic and enable for flower reps").
However, the ethtool->len == 0 check avoids the problem manifesting as a
run-time bug (NULL pointer dereference of app).
Signed-off-by: James Hershaw <james.hershaw@corigine.com>
Reviewed-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
---
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
index e9d228d7a95d..807b86667bca 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
@@ -1908,12 +1908,12 @@ nfp_net_get_eeprom(struct net_device *netdev,
struct nfp_app *app = nfp_app_from_netdev(netdev);
u8 buf[NFP_EEPROM_LEN] = {};
- if (eeprom->len == 0)
- return -EINVAL;
-
if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
return -EOPNOTSUPP;
+ if (eeprom->len == 0)
+ return -EINVAL;
+
eeprom->magic = app->pdev->vendor | (app->pdev->device << 16);
memcpy(bytes, buf + eeprom->offset, eeprom->len);
@@ -1927,15 +1927,15 @@ nfp_net_set_eeprom(struct net_device *netdev,
struct nfp_app *app = nfp_app_from_netdev(netdev);
u8 buf[NFP_EEPROM_LEN] = {};
+ if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
+ return -EOPNOTSUPP;
+
if (eeprom->len == 0)
return -EINVAL;
if (eeprom->magic != (app->pdev->vendor | app->pdev->device << 16))
return -EINVAL;
- if (nfp_net_get_port_mac_by_hwinfo(netdev, buf))
- return -EOPNOTSUPP;
-
memcpy(buf + eeprom->offset, bytes, eeprom->len);
if (nfp_net_set_port_mac_by_hwinfo(netdev, buf))
return -EOPNOTSUPP;
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom
2023-02-06 15:48 [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom Simon Horman
@ 2023-02-07 10:09 ` Leon Romanovsky
2023-02-08 4:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2023-02-07 10:09 UTC (permalink / raw)
To: Simon Horman
Cc: David Miller, Jakub Kicinski, Paolo Abeni, netdev, oss-drivers,
James Hershaw, Louis Peens
On Mon, Feb 06, 2023 at 04:48:36PM +0100, Simon Horman wrote:
> From: James Hershaw <james.hershaw@corigine.com>
>
> Move the nfp_net_get_port_mac_by_hwinfo() check to ahead in the
> get/set_eeprom() functions to in order to check for a VF netdev, which
> this function does not support.
>
> It is debatable if this is a fix or an enhancement, and we have chosen
> to go for the latter. It does address a problem introduced by
> commit 74b4f1739d4e ("nfp: flower: change get/set_eeprom logic and enable for flower reps").
> However, the ethtool->len == 0 check avoids the problem manifesting as a
> run-time bug (NULL pointer dereference of app).
>
> Signed-off-by: James Hershaw <james.hershaw@corigine.com>
> Reviewed-by: Louis Peens <louis.peens@corigine.com>
> Signed-off-by: Simon Horman <simon.horman@corigine.com>
> ---
> drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom
2023-02-06 15:48 [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom Simon Horman
2023-02-07 10:09 ` Leon Romanovsky
@ 2023-02-08 4:30 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-02-08 4:30 UTC (permalink / raw)
To: Simon Horman
Cc: davem, kuba, pabeni, netdev, oss-drivers, james.hershaw, louis.peens
Hello:
This patch was applied to netdev/net-next.git (master)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 6 Feb 2023 16:48:36 +0100 you wrote:
> From: James Hershaw <james.hershaw@corigine.com>
>
> Move the nfp_net_get_port_mac_by_hwinfo() check to ahead in the
> get/set_eeprom() functions to in order to check for a VF netdev, which
> this function does not support.
>
> It is debatable if this is a fix or an enhancement, and we have chosen
> to go for the latter. It does address a problem introduced by
> commit 74b4f1739d4e ("nfp: flower: change get/set_eeprom logic and enable for flower reps").
> However, the ethtool->len == 0 check avoids the problem manifesting as a
> run-time bug (NULL pointer dereference of app).
>
> [...]
Here is the summary with links:
- [net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom
https://git.kernel.org/netdev/net-next/c/f817554786dd
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:[~2023-02-08 4:31 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-06 15:48 [PATCH net-next] nfp: flower: add check for flower VF netdevs for get/set_eeprom Simon Horman
2023-02-07 10:09 ` Leon Romanovsky
2023-02-08 4:30 ` patchwork-bot+netdevbpf
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.