Commit 87654896 authored by Steven Whitehouse's avatar Steven Whitehouse

GFS2: More automated code analysis fixes

A potentially uninitialised variable, some unreachable code,
and the main part of this, fixing the error path in the
unlink function.
Signed-off-by: default avatarSteven Whitehouse <swhiteho@redhat.com>
parent dfe4d34b
...@@ -743,9 +743,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh, ...@@ -743,9 +743,6 @@ static int do_strip(struct gfs2_inode *ip, struct buffer_head *dibh,
else if (ip->i_depth) else if (ip->i_depth)
revokes = sdp->sd_inptrs; revokes = sdp->sd_inptrs;
if (error)
return error;
memset(&rlist, 0, sizeof(struct gfs2_rgrp_list)); memset(&rlist, 0, sizeof(struct gfs2_rgrp_list));
bstart = 0; bstart = 0;
blen = 0; blen = 0;
......
...@@ -609,7 +609,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end, ...@@ -609,7 +609,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end,
struct inode *inode = mapping->host; struct inode *inode = mapping->host;
int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC);
struct gfs2_inode *ip = GFS2_I(inode); struct gfs2_inode *ip = GFS2_I(inode);
int ret, ret1 = 0; int ret = 0, ret1 = 0;
if (mapping->nrpages) { if (mapping->nrpages) {
ret1 = filemap_fdatawrite_range(mapping, start, end); ret1 = filemap_fdatawrite_range(mapping, start, end);
......
...@@ -1037,12 +1037,14 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1037,12 +1037,14 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
struct buffer_head *bh; struct buffer_head *bh;
struct gfs2_holder ghs[3]; struct gfs2_holder ghs[3];
struct gfs2_rgrpd *rgd; struct gfs2_rgrpd *rgd;
int error; int error = -EROFS;
gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs); gfs2_holder_init(dip->i_gl, LM_ST_EXCLUSIVE, 0, ghs);
gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1); gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, ghs + 1);
rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr); rgd = gfs2_blk2rgrpd(sdp, ip->i_no_addr);
if (!rgd)
goto out_inodes;
gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2); gfs2_holder_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, ghs + 2);
...@@ -1088,12 +1090,13 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry) ...@@ -1088,12 +1090,13 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
out_gunlock: out_gunlock:
gfs2_glock_dq(ghs + 2); gfs2_glock_dq(ghs + 2);
out_rgrp: out_rgrp:
gfs2_holder_uninit(ghs + 2);
gfs2_glock_dq(ghs + 1); gfs2_glock_dq(ghs + 1);
out_child: out_child:
gfs2_holder_uninit(ghs + 1);
gfs2_glock_dq(ghs); gfs2_glock_dq(ghs);
out_parent: out_parent:
gfs2_holder_uninit(ghs + 2);
out_inodes:
gfs2_holder_uninit(ghs + 1);
gfs2_holder_uninit(ghs); gfs2_holder_uninit(ghs);
return error; return error;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment