[dpdk-dev] [PATCH] net/mlx5: add missing return value check

Dekel Peled dekelp at mellanox.com
Thu Mar 21 10:34:27 CET 2019


> -----Original Message-----
> From: Ali Alnubani
> Sent: Thursday, March 21, 2019 11:07 AM
> To: dev at dpdk.org
> Cc: Shahaf Shuler <shahafs at mellanox.com>; Dekel Peled
> <dekelp at mellanox.com>
> Subject: [PATCH] net/mlx5: add missing return value check
> 
> Fixes: d86406b965df ("net/mlx5: support new representor naming format")
> Cc: dekelp at mellanox.com
> 
> Signed-off-by: Ali Alnubani <alialnu at mellanox.com>
> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c
> b/drivers/net/mlx5/mlx5_ethdev.c index 84d761c8e..1fd988998 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -1365,6 +1365,7 @@ mlx5_sysfs_switch_info(unsigned int ifindex, struct
> mlx5_switch_info *info)
>  	bool port_name_set = false;
>  	bool port_switch_id_set = false;
>  	char c;
> +	int ret;
> 
>  	if (!if_indextoname(ifindex, ifname)) {
>  		rte_errno = errno;
> @@ -1378,9 +1379,10 @@ mlx5_sysfs_switch_info(unsigned int ifindex,
> struct mlx5_switch_info *info)
> 
>  	file = fopen(phys_port_name, "rb");
>  	if (file != NULL) {
> -		fscanf(file, "%s", port_name);
> +		ret = fscanf(file, "%s", port_name);
>  		fclose(file);
> -		port_name_set = mlx5_translate_port_name(port_name,
> &data);
> +		if (ret == 1)
> +			port_name_set =
> mlx5_translate_port_name(port_name, &data);
>  	}
>  	file = fopen(phys_switch_id, "rb");
>  	if (file == NULL) {
> --
> 2.19.2

Acked by: Dekel Peled <dekelp at mellanox.com>


More information about the dev mailing list