linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: trix@redhat.com
To: viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	Tom Rix <trix@redhat.com>
Subject: [PATCH] fs : initialize return for iter_file_splice_write
Date: Wed, 17 Jun 2020 06:07:11 -0700	[thread overview]
Message-ID: <20200617130711.23434-1-trix@redhat.com> (raw)

From: Tom Rix <trix@redhat.com>

clang static analysis flags this garbarge return
fs/splice.c:786:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn]
        return ret;
        ^~~~~~~~~~

ssize_t
iter_file_splice_write( ... size_t len, ..
	sd.total_len = len

	ssize_t ret;

	while (sd.total_len) {
	      ...
	      ret =
	}

If the input len is 0, the while loop will never run and ret will
not be set.

So handle similar to splice_direct_to_actor and initialize ret to 0

Signed-off-by: Tom Rix <trix@redhat.com>
---
 fs/splice.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/splice.c b/fs/splice.c
index d7c8a7c4db07..f65e072bcc2c 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -691,7 +691,7 @@ iter_file_splice_write(struct pipe_inode_info *pipe, struct file *out,
 	int nbufs = pipe->max_usage;
 	struct bio_vec *array = kcalloc(nbufs, sizeof(struct bio_vec),
 					GFP_KERNEL);
-	ssize_t ret;
+	ssize_t ret = 0;
 
 	if (unlikely(!array))
 		return -ENOMEM;
-- 
2.18.1


                 reply	other threads:[~2020-06-17 13:07 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200617130711.23434-1-trix@redhat.com \
    --to=trix@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).