netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
@ 2020-01-19 12:41 Chen Zhou
  2020-01-20  1:28 ` tanhuazhong
  0 siblings, 1 reply; 3+ messages in thread
From: Chen Zhou @ 2020-01-19 12:41 UTC (permalink / raw)
  To: yisen.zhuang, salil.mehta, davem; +Cc: netdev, linux-kernel, chenzhou10

The return value of snprintf may be greater than the size of
HNS3_DBG_READ_LEN, use scnprintf instead in hns3_dbg_cmd_read.

Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
---
 drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 6b328a2..8fad699 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
@@ -297,7 +297,7 @@ static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
 	if (!buf)
 		return -ENOMEM;
 
-	len = snprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
+	len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
 		       "Please echo help to cmd to get help information");
 	uncopy_bytes = copy_to_user(buffer, buf, len);
 
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
  2020-01-19 12:41 [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read Chen Zhou
@ 2020-01-20  1:28 ` tanhuazhong
  2020-01-20  2:37   ` Chen Zhou
  0 siblings, 1 reply; 3+ messages in thread
From: tanhuazhong @ 2020-01-20  1:28 UTC (permalink / raw)
  To: Chen Zhou, yisen.zhuang, salil.mehta, davem; +Cc: netdev, linux-kernel



On 2020/1/19 20:41, Chen Zhou wrote:
> The return value of snprintf may be greater than the size of
> HNS3_DBG_READ_LEN, use scnprintf instead in hns3_dbg_cmd_read.
> 
> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
> ---
>   drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> index 6b328a2..8fad699 100644
> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
> @@ -297,7 +297,7 @@ static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
>   	if (!buf)
>   		return -ENOMEM;
>   
> -	len = snprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
> +	len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
>   		       "Please echo help to cmd to get help information");

not align?

>   	uncopy_bytes = copy_to_user(buffer, buf, len);
>   
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read
  2020-01-20  1:28 ` tanhuazhong
@ 2020-01-20  2:37   ` Chen Zhou
  0 siblings, 0 replies; 3+ messages in thread
From: Chen Zhou @ 2020-01-20  2:37 UTC (permalink / raw)
  To: tanhuazhong, yisen.zhuang, salil.mehta, davem; +Cc: netdev, linux-kernel



On 2020/1/20 9:28, tanhuazhong wrote:
> 
> 
> On 2020/1/19 20:41, Chen Zhou wrote:
>> The return value of snprintf may be greater than the size of
>> HNS3_DBG_READ_LEN, use scnprintf instead in hns3_dbg_cmd_read.
>>
>> Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
>> ---
>>   drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> index 6b328a2..8fad699 100644
>> --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
>> @@ -297,7 +297,7 @@ static ssize_t hns3_dbg_cmd_read(struct file *filp, char __user *buffer,
>>       if (!buf)
>>           return -ENOMEM;
>>   -    len = snprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
>> +    len = scnprintf(buf, HNS3_DBG_READ_LEN, "%s\n",
>>                  "Please echo help to cmd to get help information");
> 
> not align?

Ok, i will fix in next version.

Thanks,
Chen Zhou

> 
>>       uncopy_bytes = copy_to_user(buffer, buf, len);
>>  
> 
> 
> .
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-01-20  2:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-19 12:41 [PATCH -next] net: hns3: replace snprintf with scnprintf in hns3_dbg_cmd_read Chen Zhou
2020-01-20  1:28 ` tanhuazhong
2020-01-20  2:37   ` Chen Zhou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).