lkml.org 
[lkml]   [2023]   [Sep]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2] Input: axp20x-pek - avoid needless newline removal
On Tue, Sep 26, 2023 at 2:00 AM Kees Cook <keescook@chromium.org> wrote:
>
> On Mon, Sep 25, 2023 at 04:31:05AM +0000, Justin Stitt wrote:
> > This code is doing more work than it needs to.
> >
> > Before handing off `val_str` to `kstrtouint()` we are eagerly removing
> > any trailing newline which requires copying `buf`, validating it's
> > length and checking/replacing any potential newlines.
> >
> > kstrtouint() handles this implicitly:
> > kstrtouint ->
> > kstrotoull -> (documentation)
> > | /**
> > | * kstrtoull - convert a string to an unsigned long long
> > | * @s: The start of the string. The string must be null-terminated, and may also
> > | * include a single newline before its terminating null. The first character
> > | ...
> >
> > Let's remove the redundant functionality and let kstrtouint handle it.
> >
> > Link: https://github.com/KSPP/linux/issues/90
> > Cc: linux-hardening@vger.kernel.org
> > Suggested-by: Kees Cook <keescook@chromium.org>
> > Signed-off-by: Justin Stitt <justinstitt@google.com>
>
> This looks much cleaner. Thanks!
>
> Reviewed-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Chen-Yu Tsai <wens@csie.org>

\
 
 \ /
  Last update: 2023-09-26 05:11    [W:0.814 / U:0.904 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site