[PATCH] fs : initialize return for iter_file_splice_write

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Tom Rix <trix@xxxxxxxxxx>

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@xxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux