]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool()
authorSu Hui <suhui@nfschina.com>
Wed, 5 Jun 2024 03:47:43 +0000 (11:47 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 19 Jan 2026 12:10:13 +0000 (13:10 +0100)
commit 0dcc53abf58d572d34c5313de85f607cd33fc691 upstream.

Clang static checker (scan-build) warning:
net/ethtool/ioctl.c:line 2233, column 2
Called function pointer is null (null dereference).

Return '-EOPNOTSUPP' when 'ops->get_ethtool_phy_stats' is NULL to fix
this typo error.

Fixes: 201ed315f967 ("net/ethtool/ioctl: split ethtool_get_phy_stats into multiple helpers")
Signed-off-by: Su Hui <suhui@nfschina.com>
Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
Link: https://lore.kernel.org/r/20240605034742.921751-1-suhui@nfschina.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ethtool/ioctl.c

index 81fe585ddfa915bd174628beeca13fc36a29495f..8f44bdae78bf7b9628ca893be67169096b3c0ee4 100644 (file)
@@ -2111,7 +2111,7 @@ static int ethtool_get_phy_stats_ethtool(struct net_device *dev,
        const struct ethtool_ops *ops = dev->ethtool_ops;
        int n_stats, ret;
 
-       if (!ops || !ops->get_sset_count || ops->get_ethtool_phy_stats)
+       if (!ops || !ops->get_sset_count || !ops->get_ethtool_phy_stats)
                return -EOPNOTSUPP;
 
        n_stats = ops->get_sset_count(dev, ETH_SS_PHY_STATS);