summaryrefslogtreecommitdiffstats
path: root/fs/gfs2/trans.c
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2015-10-01 11:47:31 -0500
committerBob Peterson <rpeterso@redhat.com>2015-10-01 12:00:59 -0500
commit491e94f790982bec5a1334dd3db2708de3724bdf (patch)
tree710667725821e752d23d6bb1b829bbe6cee0b958 /fs/gfs2/trans.c
parent6de20eb0dee4c802d9d228d6c08d00386e172e52 (diff)
downloadlinux-stable-491e94f790982bec5a1334dd3db2708de3724bdf.tar.gz
linux-stable-491e94f790982bec5a1334dd3db2708de3724bdf.tar.bz2
linux-stable-491e94f790982bec5a1334dd3db2708de3724bdf.zip
gfs2: Add missing else in trans_add_meta/data
This patch fixes a timing window that causes a segfault. The problem is that bd can remain NULL throughout the function and then reference that NULL pointer if the bh->b_private starts out NULL, then someone sets it to non-NULL inside the locking. In that case, bd still needs to be set. Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Diffstat (limited to 'fs/gfs2/trans.c')
-rw-r--r--fs/gfs2/trans.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/gfs2/trans.c b/fs/gfs2/trans.c
index b95d0d625f32..0c1bde395062 100644
--- a/fs/gfs2/trans.c
+++ b/fs/gfs2/trans.c
@@ -176,6 +176,8 @@ void gfs2_trans_add_data(struct gfs2_glock *gl, struct buffer_head *bh)
unlock_buffer(bh);
if (bh->b_private == NULL)
bd = gfs2_alloc_bufdata(gl, bh, &gfs2_databuf_lops);
+ else
+ bd = bh->b_private;
lock_buffer(bh);
gfs2_log_lock(sdp);
}
@@ -236,6 +238,8 @@ void gfs2_trans_add_meta(struct gfs2_glock *gl, struct buffer_head *bh)
lock_page(bh->b_page);
if (bh->b_private == NULL)
bd = gfs2_alloc_bufdata(gl, bh, &gfs2_buf_lops);
+ else
+ bd = bh->b_private;
unlock_page(bh->b_page);
lock_buffer(bh);
gfs2_log_lock(sdp);