]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfp: add port from netdev validation for EEPROM access
authorJaco Coetzee <jaco.coetzee@corigine.com>
Thu, 17 Nov 2022 15:37:44 +0000 (16:37 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 Dec 2022 16:40:00 +0000 (17:40 +0100)
[ Upstream commit 0873016d46f6dfafd1bdf4d9b935b3331b226f7c ]

Setting of the port flag `NFP_PORT_CHANGED`, introduced
to ensure the correct reading of EEPROM data, causes a
fatal kernel NULL pointer dereference in cases where
the target netdev type cannot be determined.

Add validation of port struct pointer before attempting
to set the `NFP_PORT_CHANGED` flag. Return that operation
is not supported if the netdev type cannot be determined.

Fixes: 4ae97cae07e1 ("nfp: ethtool: fix the display error of `ethtool -m DEVNAME`")
Signed-off-by: Jaco Coetzee <jaco.coetzee@corigine.com>
Reviewed-by: Louis Peens <louis.peens@corigine.com>
Signed-off-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c

index 3977aa2f59bd1681558e456ec31738c8cc837aa5..311873ff57e33117dd379d92a89b7362aa572d2b 100644 (file)
@@ -1225,6 +1225,9 @@ nfp_port_get_module_info(struct net_device *netdev,
        u8 data;
 
        port = nfp_port_from_netdev(netdev);
+       if (!port)
+               return -EOPNOTSUPP;
+
        /* update port state to get latest interface */
        set_bit(NFP_PORT_CHANGED, &port->flags);
        eth_port = nfp_port_get_eth_port(port);