Skip to content

Commit 977b7e3

Browse files
author
Wu Fengguang
committed
writeback: fix dereferencing NULL bdi->dev on trace_writeback_queue
When a SD card is hot removed without umount, del_gendisk() will call bdi_unregister() without destroying/freeing it. This leaves the bdi in the bdi->dev = NULL, bdi->wb.task = NULL, bdi->bdi_list removed state. When sync(2) gets the bdi before bdi_unregister() and calls bdi_queue_work() after the unregister, trace_writeback_queue will be dereferencing the NULL bdi->dev. Fix it with a simple test for NULL. LKML-reference: http://lkml.org/lkml/2012/1/18/346 Cc: [email protected] Reported-by: Rabin Vincent <[email protected]> Tested-by: Namjae Jeon <[email protected]> Signed-off-by: Wu Fengguang <[email protected]>
1 parent 3310225 commit 977b7e3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

include/trace/events/writeback.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ DECLARE_EVENT_CLASS(writeback_work_class,
4747
__field(int, reason)
4848
),
4949
TP_fast_assign(
50-
strncpy(__entry->name, dev_name(bdi->dev), 32);
50+
struct device *dev = bdi->dev;
51+
if (!dev)
52+
dev = default_backing_dev_info.dev;
53+
strncpy(__entry->name, dev_name(dev), 32);
5154
__entry->nr_pages = work->nr_pages;
5255
__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
5356
__entry->sync_mode = work->sync_mode;

0 commit comments

Comments
 (0)