[PATCH 3/7] logfs: fix error return code

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

 



From: Julia Lawall <Julia.Lawall@xxxxxxx>

Initialize return variable before exiting on an error path.

A simplified version of the semantic match that finds this problem is as
follows: (http://coccinelle.lip6.fr/)

// <smpl>
(
if@p1 (\(ret < 0\|ret != 0\))
 { ... return ret; }
|
ret@p1 = 0
)
... when != ret = e1
    when != &ret
*if(...)
{
  ... when != ret = e2
      when forall
 return ret;
}

// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@xxxxxxx>

---
 fs/logfs/segment.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/logfs/segment.c b/fs/logfs/segment.c
index 038da09..0cf91e4 100644
--- a/fs/logfs/segment.c
+++ b/fs/logfs/segment.c
@@ -601,6 +601,7 @@ static int __logfs_segment_read(struct inode *inode, void *buf,
 					"%llx: expected %x, got %x\n", ofs,
 					be32_to_cpu(oh.data_crc),
 					be32_to_cpu(crc));
+			err = -EIO;
 			goto out_err;
 		}
 		break;
@@ -619,6 +620,7 @@ static int __logfs_segment_read(struct inode *inode, void *buf,
 					be32_to_cpu(oh.data_crc),
 					be32_to_cpu(crc));
 			mutex_unlock(&logfs_super(sb)->s_journal_mutex);
+			err = -EIO;
 			goto out_err;
 		}
 		err = logfs_uncompress(compressor_buf, buf, len, block_len);

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux