Re: [PATCH net-next v6 4/9] ethtool: Add flashing transceiver modules' firmware notifications ability

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 19, 2024 at 03:17:22PM +0300, Danielle Ratson wrote:
> Add progress notifications ability to user space while flashing modules'
> firmware by implementing the interface between the user space and the
> kernel.
> 
> Signed-off-by: Danielle Ratson <danieller@xxxxxxxxxx>
> Reviewed-by: Petr Machata <petrm@xxxxxxxxxx>

...

> diff --git a/net/ethtool/module.c b/net/ethtool/module.c

...

> @@ -158,3 +159,119 @@ const struct ethnl_request_ops ethnl_module_request_ops = {
>  	.set			= ethnl_set_module,
>  	.set_ntf_cmd		= ETHTOOL_MSG_MODULE_NTF,
>  };
> +
> +/* MODULE_FW_FLASH_NTF */
> +
> +static int
> +ethnl_module_fw_flash_ntf_put_err(struct sk_buff *skb, char *err_msg,
> +				  char *sub_err_msg)
> +{
> +	int err_msg_len, sub_err_msg_len, total_len;
> +	struct nlattr *attr;
> +
> +	if (!err_msg)
> +		return 0;
> +
> +	err_msg_len = strlen(err_msg);
> +	total_len = err_msg_len + 2; /* For period and NUL. */
> +
> +	if (sub_err_msg) {
> +		sub_err_msg_len = strlen(sub_err_msg);
> +		total_len += sub_err_msg_len + 2; /* For ", ". */
> +	}
> +
> +	attr = nla_reserve(skb, ETHTOOL_A_MODULE_FW_FLASH_STATUS_MSG,
> +			   total_len);
> +	if (!attr)
> +		return PTR_ERR(attr);

Hi Danielle,

attr is NULL here, so I think this will return 0.
Perhaps it should return an negative error value,
say -ENOMEM, instead?

Flagged by Smatch

> +
> +	if (sub_err_msg)
> +		sprintf(nla_data(attr), "%s, %s.", err_msg, sub_err_msg);
> +	else
> +		sprintf(nla_data(attr), "%s.", err_msg);
> +
> +	return 0;
> +}

...




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux