From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "Wang, Li" <li.wang@windriver.com>,
jirislaby@kernel.org, dmitry.torokhov@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] vt: keyboard, fix uninitialized variables warning
Date: Wed, 3 Mar 2021 10:24:25 +0200 [thread overview]
Message-ID: <YD9HufAwwxK2jZwD@smile.fi.intel.com> (raw)
In-Reply-To: <YD89HVVBREVdqdpJ@kroah.com>
On Wed, Mar 03, 2021 at 08:39:09AM +0100, Greg KH wrote:
> On Wed, Mar 03, 2021 at 03:33:23PM +0800, Wang, Li wrote:
> > On 3/3/2021 3:14 PM, Greg KH wrote:
> > > On Wed, Mar 03, 2021 at 12:59:32PM +0800, Li Wang wrote:
> > > > drivers/tty/vt/keyboard.c: In function 'vt_do_kdgkb_ioctl':
> > > > drivers/tty/vt/keyboard.c: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
> > > > return ret;
> > > > ^~~
> > > > kernel-source/drivers/tty/vt/keyboard.c: warning: 'kbs' may be used uninitialized in this function [-Wmaybe-uninitialized]
> > > > kfree(kbs);
> > > > ^~~~~~~~~~
> > > >
> > > > Signed-off-by: Li Wang <li.wang@windriver.com>
> > > > ---
> > > > drivers/tty/vt/keyboard.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
> > > > index 7763862..3e73d55 100644
> > > > --- a/drivers/tty/vt/keyboard.c
> > > > +++ b/drivers/tty/vt/keyboard.c
> > > > @@ -2049,8 +2049,8 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
> > > > {
> > > > unsigned char kb_func;
> > > > unsigned long flags;
> > > > - char *kbs;
> > > > - int ret;
> > > > + char *kbs = NULL;
> > > > + int ret = -EINVAL;
> > > > if (get_user(kb_func, &user_kdgkb->kb_func))
> > > > return -EFAULT;
> > > What compiler is providing these "warnings"?
> > >
> > > Turns out it is impossible to hit, so this isn't actually fixing
> > > anything...
> >
> > I tested it with gcc 8.2 for arm
> >
> > for runtime codes view, indeed it is impossible to hit.
> >
> > but for compiler view, gcc should give 'used uninitialized' warning, too.
>
> Odd that no other compiler version does this right now, perhaps upgrade
> to a newer version of gcc? 8.2 is really old :(
But it's still supported. I think I can see why. We have a switch case without
default, and probably that's how it makes that happen. So, the proper fix is to
add default section AFAICT.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2021-03-03 15:46 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-03 4:59 Li Wang
2021-03-03 7:14 ` Greg KH
2021-03-03 7:33 ` Wang, Li
2021-03-03 7:39 ` Greg KH
2021-03-03 8:24 ` Andy Shevchenko [this message]
2021-03-03 9:21 ` Wang, Li
2021-03-04 3:10 ` [V2][PATCH] " Li Wang
2021-03-04 7:03 ` Jiri Slaby
2021-03-04 7:04 ` Greg KH
2021-03-04 12:28 ` Andy Shevchenko
2021-03-04 12:30 ` Andy Shevchenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YD9HufAwwxK2jZwD@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=dmitry.torokhov@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=li.wang@windriver.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®