linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@kernel.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Arnd Bergmann <arnd@arndb.de>, kernel test robot <lkp@intel.com>,
	Dan Carpenter <error27@gmail.com>,
	Erick Archer <erick.archer@outlook.com>,
	linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Input: serio_raw - initialize serio_raw_write() the return code
Date: Mon, 21 Oct 2024 10:38:27 +0000	[thread overview]
Message-ID: <20241021103839.2828469-1-arnd@kernel.org> (raw)

From: Arnd Bergmann <arnd@arndb.de>

The number of bytes returned from the write function is now
undefined:

drivers/input/serio/serio_raw.c:204:12: error: variable 'written' is uninitialized when used here [-Werror,-Wuninitialized]
  204 |                                 return written ?: -EIO;
      |                                        ^~~~~~~

Fixes: 5b53a9d40c4f ("Input: serio_raw - use guard notation for locks and other resources")
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202410201730.ItNhUTIv-lkp@intel.com/
Closes: https://lore.kernel.org/r/202410201759.qnyACw46-lkp@intel.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/input/serio/serio_raw.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
index e058fef07f57..55fe77d04089 100644
--- a/drivers/input/serio/serio_raw.c
+++ b/drivers/input/serio/serio_raw.c
@@ -195,6 +195,7 @@ static ssize_t serio_raw_write(struct file *file, const char __user *buffer,
 		if (count > 32)
 			count = 32;
 
+		written = 0;
 		while (count--) {
 			if (get_user(c, buffer++))
 				return -EFAULT;
-- 
2.39.5


             reply	other threads:[~2024-10-21 10:38 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-21 10:38 Arnd Bergmann [this message]
2024-10-21 19:19 ` [PATCH] Input: serio_raw - initialize serio_raw_write() the return code Dmitry Torokhov

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=20241021103839.2828469-1-arnd@kernel.org \
    --to=arnd@kernel.org \
    --cc=arnd@arndb.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=erick.archer@outlook.com \
    --cc=error27@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).