summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2012-02-04 20:54:03 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-02-20 12:46:17 -0800
commit422204b77968331ce85721527f7ece49f72658f2 (patch)
treed240880498bd55da47b97fcce0c64637fc1c14dc
parentaec14f459cc9d40f9fd4a7aad2be761de084b320 (diff)
downloadlwn-422204b77968331ce85721527f7ece49f72658f2.tar.gz
lwn-422204b77968331ce85721527f7ece49f72658f2.zip
writeback: fix dereferencing NULL bdi->dev on trace_writeback_queue
commit 977b7e3a52a7421ad33a393a38ece59f3d41c2fa upstream. 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 Reported-by: Rabin Vincent <rabin@rab.in> Tested-by: Namjae Jeon <linkinjeon@gmail.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--include/trace/events/writeback.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/include/trace/events/writeback.h b/include/trace/events/writeback.h
index 46e389cf3063..1f48f148f86a 100644
--- a/include/trace/events/writeback.h
+++ b/include/trace/events/writeback.h
@@ -47,7 +47,10 @@ DECLARE_EVENT_CLASS(writeback_work_class,
__field(int, reason)
),
TP_fast_assign(
- strncpy(__entry->name, dev_name(bdi->dev), 32);
+ struct device *dev = bdi->dev;
+ if (!dev)
+ dev = default_backing_dev_info.dev;
+ strncpy(__entry->name, dev_name(dev), 32);
__entry->nr_pages = work->nr_pages;
__entry->sb_dev = work->sb ? work->sb->s_dev : 0;
__entry->sync_mode = work->sync_mode;