lkml.org 
[lkml]   [2020]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next 1/5] ptp: clockmatrix: bug fix for idtcm_strverscmp
On Mon, 16 Nov 2020 14:27:26 -0500 min.li.xe@renesas.com wrote:
> From: Min Li <min.li.xe@renesas.com>
>
> Feed kstrtou8 with NULL terminated string.

Is this a fix? Does it need to be backported to stable?

Also please add a cover letter for the series describing the overall
goal of this work, what testing has been done etc.

> drivers/ptp/ptp_clockmatrix.c | 52 +++++++++++++++++++++++++++++++------------
> 1 file changed, 38 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/ptp/ptp_clockmatrix.c b/drivers/ptp/ptp_clockmatrix.c
> index e020faf..bf2be50 100644
> --- a/drivers/ptp/ptp_clockmatrix.c
> +++ b/drivers/ptp/ptp_clockmatrix.c
> @@ -103,42 +103,66 @@ static int timespec_to_char_array(struct timespec64 const *ts,
> return 0;
> }
>
> -static int idtcm_strverscmp(const char *ver1, const char *ver2)
> +static int idtcm_strverscmp(const char *version1, const char *version2)
> {
> u8 num1;
> u8 num2;
> int result = 0;
> + char ver1[16];
> + char ver2[16];
> + char *cur1;
> + char *cur2;
> + char *next1;
> + char *next2;
> +
> + strncpy(ver1, version1, 16);
> + strncpy(ver2, version2, 16);

This patch triggers the following warning on a 32bit build:

In file included from ../arch/x86/include/asm/page_32.h:35,
from ../arch/x86/include/asm/page.h:14,
from ../arch/x86/include/asm/thread_info.h:12,
from ../include/linux/thread_info.h:38,
from ../arch/x86/include/asm/preempt.h:7,
from ../include/linux/preempt.h:78,
from ../include/linux/spinlock.h:51,
from ../include/linux/mmzone.h:8,
from ../include/linux/gfp.h:6,
from ../include/linux/firmware.h:7,
from ../drivers/ptp/ptp_clockmatrix.c:8:
In function ‘strncpy’,
inlined from ‘idtcm_strverscmp.constprop’ at ../drivers/ptp/ptp_clockmatrix.c:118:2:
../include/linux/string.h:290:30: warning: ‘__builtin_strncpy’ specified bound 16 equals destination size [-Wstringop-truncation]
290 | #define __underlying_strncpy __builtin_strncpy
| ^
../include/linux/string.h:300:9: note: in expansion of macro ‘__underlying_strncpy’
300 | return __underlying_strncpy(p, q, size);
| ^~~~~~~~~~~~~~~~~~~~

\
 
 \ /
  Last update: 2020-11-17 02:29    [W:0.068 / U:0.520 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site