diff mbox series

[net] net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool()

Message ID 20240605034742.921751-1-suhui@nfschina.com (mailing list archive)
State Accepted
Commit 0dcc53abf58d572d34c5313de85f607cd33fc691
Delegated to: Netdev Maintainers
Headers show
Series [net] net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool() | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 902 this patch: 902
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 12 of 12 maintainers
netdev/build_clang success Errors and warnings before: 904 this patch: 904
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 906 this patch: 906
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-06-05--06-00 (tests: 1043)

Commit Message

Su Hui June 5, 2024, 3:47 a.m. UTC
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>
---
 net/ethtool/ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Przemek Kitszel June 5, 2024, 4:05 a.m. UTC | #1
On 6/5/24 05:47, Su Hui wrote:
> 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>
> ---
>   net/ethtool/ioctl.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
> index 5a55270aa86e..e645d751a5e8 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -2220,7 +2220,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);

Thank you,
both the change and provided Fixes tag are correct.

Reviewed-by: Przemek Kitszel <przemyslaw.kitszel@intel.com>
Hariprasad Kelam June 5, 2024, 7 a.m. UTC | #2
> 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>
> ---
>  net/ethtool/ioctl.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index
> 5a55270aa86e..e645d751a5e8 100644
> --- a/net/ethtool/ioctl.c
> +++ b/net/ethtool/ioctl.c
> @@ -2220,7 +2220,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);
> --
> 2.30.2
> 
Good catch!!

Reviewed-by: Hariprasad Kelam <hkelam@marvell.com>
patchwork-bot+netdevbpf@kernel.org June 6, 2024, 11:40 a.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Wed,  5 Jun 2024 11:47:43 +0800 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [net] net: ethtool: fix the error condition in ethtool_get_phy_stats_ethtool()
    https://git.kernel.org/netdev/net/c/0dcc53abf58d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 5a55270aa86e..e645d751a5e8 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -2220,7 +2220,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);