public inbox for linux-serial@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Purva Yeshi <purvayeshi550@gmail.com>
Cc: jirislaby@kernel.org, tglx@linutronix.de, hdegoede@redhat.com,
	mingo@kernel.org, linux-kernel@vger.kernel.org,
	linux-serial@vger.kernel.org
Subject: Re: [PATCH] tty: vt: keyboard: Fix uninitialized variables in vt_do_kdgkb_ioctl
Date: Fri, 11 Apr 2025 13:28:01 +0200	[thread overview]
Message-ID: <2025041107-postbox-bonanza-2049@gregkh> (raw)
In-Reply-To: <20250411111548.31399-1-purvayeshi550@gmail.com>

On Fri, Apr 11, 2025 at 04:45:48PM +0530, Purva Yeshi wrote:
> Fix Smatch-detected issue:
> 
> drivers/tty/vt/keyboard.c:2106 vt_do_kdgkb_ioctl() error:
> uninitialized symbol 'kbs'.
> drivers/tty/vt/keyboard.c:2108 vt_do_kdgkb_ioctl() error:
> uninitialized symbol 'ret'.
> 
> Fix uninitialized variable warnings reported by Smatch in
> vt_do_kdgkb_ioctl(). The variables kbs and ret were used in the kfree
> and return statements without guaranteed initialization paths, leading to
> potential undefined behavior or false positives during static analysis.
> 
> Initialize char *kbs to NULL and int ret to -EINVAL at declaration.
> This ensures safe use of kfree(kbs) and return ret regardless of control
> flow. Also add a default case in the switch to preserve fallback behavior.

When you say "also" in a patch, that is a HUGE flag that this should be
split up into a separate change.  Please do that here, don't mix changes
that have nothing to do with each other together into one.

Also, why isn't the compilers noticing that these are uninitialized
variables?  Are you sure the warning is correct?

thanks,

greg k-h

  reply	other threads:[~2025-04-11 11:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 11:15 [PATCH] tty: vt: keyboard: Fix uninitialized variables in vt_do_kdgkb_ioctl Purva Yeshi
2025-04-11 11:28 ` Greg KH [this message]
2025-04-11 13:18   ` Purva Yeshi
2025-04-11 14:15     ` Greg KH

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=2025041107-postbox-bonanza-2049@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=jirislaby@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-serial@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=purvayeshi550@gmail.com \
    --cc=tglx@linutronix.de \
    /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