bcache: Fix a null ptr deref regression
authorKent Overstreet <kmo@daterainc.com>
Fri, 11 Oct 2013 00:31:15 +0000 (17:31 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 13 Oct 2013 23:08:35 +0000 (16:08 -0700)
commit 2fe80d3bbf1c8bd9efc5b8154207c8dd104e7306 upstream.

Commit c0f04d88e46d ("bcache: Fix flushes in writeback mode") was fixing
a reported data corruption bug, but it seems some last minute
refactoring or rebasing introduced a null pointer deref.

Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Reported-by: Gabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/bcache/request.c

index 2fe37fac1ca2047e32aaa50ee4f14000a3fc3aff..cbcf8b301edc374f5e4392923867b580aa704e2f 100644 (file)
@@ -1055,6 +1055,7 @@ static void request_write(struct cached_dev *dc, struct search *s)
        } else {
                trace_bcache_writeback(s->orig_bio);
                bch_writeback_add(dc, bio_sectors(bio));
+               s->op.cache_bio = bio;
 
                if (bio->bi_rw & REQ_FLUSH) {
                        /* Also need to send a flush to the backing device */
@@ -1067,8 +1068,6 @@ static void request_write(struct cached_dev *dc, struct search *s)
                        flush->bi_private = cl;
 
                        closure_bio_submit(flush, cl, s->d);
-               } else {
-                       s->op.cache_bio = bio;
                }
        }
 out: