[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <55e07c56-da57-41aa-bc96-e446fad24276@intel.com>
Date: Wed, 15 Nov 2023 16:39:27 +0100
From: Alexander Lobakin <aleksander.lobakin@...el.com>
To: Kunwu Chan <chentao@...inos.cn>
CC: <horms@...nel.org>, <anthony.l.nguyen@...el.com>,
<davem@...emloft.net>, <edumazet@...gle.com>,
<intel-wired-lan@...ts.osuosl.org>, <jeffrey.t.kirsher@...el.com>,
<jesse.brandeburg@...el.com>, <kuba@...nel.org>,
<kunwu.chan@...mail.com>, <linux-kernel@...r.kernel.org>,
<netdev@...r.kernel.org>, <pabeni@...hat.com>,
<shannon.nelson@....com>
Subject: Re: [PATCH iwl-next] i40e: Use correct buffer size
From: Kunwu Chan <chentao@...inos.cn>
Date: Wed, 15 Nov 2023 11:14:44 +0800
> The size of "i40e_dbg_command_buf" is 256, the size of "name"
> depends on "IFNAMSIZ", plus a null character and format size,
> the total size is more than 256, fix it.
>
> Signed-off-by: Kunwu Chan <chentao@...inos.cn>
> Suggested-by: Simon Horman <horms@...nel.org>
> ---
> drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> index 999c9708def5..e3b939c67cfe 100644
> --- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> +++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
> @@ -72,7 +72,7 @@ static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer,
> {
> struct i40e_pf *pf = filp->private_data;
> int bytes_not_copied;
> - int buf_size = 256;
> + int buf_size = IFNAMSIZ + sizeof(i40e_dbg_command_buf) + 4;
Reverse Christmas Tree style? Should be the first one in the declaration
list.
> char *buf;
> int len;
You can fix it in a different way. Given that there's a kzalloc() either
way, why not allocate the precise required amount of bytes by using
kasprintf() instead of kzalloc() + snprintf()? You wouldn't need to
calculate any buffer sizes etc. this way.
Thanks,
Olek
Powered by blists - more mailing lists