linux-stable/drivers/md/bcache
Eric Wheeler 9b299728ed bcache: cleaned up error handling around register_cache()
Fix null pointer dereference by changing register_cache() to return an int
instead of being void.  This allows it to return -ENOMEM or -ENODEV and
enables upper layers to handle the OOM case without NULL pointer issues.

See this thread:
  http://thread.gmane.org/gmane.linux.kernel.bcache.devel/3521

Fixes this error:
  gargamel:/sys/block/md5/bcache# echo /dev/sdh2 > /sys/fs/bcache/register

  bcache: register_cache() error opening sdh2: cannot allocate memory
  BUG: unable to handle kernel NULL pointer dereference at 00000000000009b8
  IP: [<ffffffffc05a7e8d>] cache_set_flush+0x102/0x15c [bcache]
  PGD 120dff067 PUD 1119a3067 PMD 0
  Oops: 0000 [#1] SMP
  Modules linked in: veth ip6table_filter ip6_tables
  (...)
  CPU: 4 PID: 3371 Comm: kworker/4:3 Not tainted 4.4.2-amd64-i915-volpreempt-20160213bc1 #3
  Hardware name: System manufacturer System Product Name/P8H67-M PRO, BIOS 3904 04/27/2013
  Workqueue: events cache_set_flush [bcache]
  task: ffff88020d5dc280 ti: ffff88020b6f8000 task.ti: ffff88020b6f8000
  RIP: 0010:[<ffffffffc05a7e8d>]  [<ffffffffc05a7e8d>] cache_set_flush+0x102/0x15c [bcache]

Signed-off-by: Eric Wheeler <bcache@linux.ewheeler.net>
Tested-by: Marc MERLIN <marc@merlins.org>
Cc: <stable@vger.kernel.org>
2016-03-08 09:19:08 -07:00
..
alloc.c bcache allocator: send discards with correct size 2014-08-04 15:23:03 -07:00
bcache.h bcache: remove driver private bio splitting code 2015-08-13 12:31:40 -06:00
bset.c bcache: Allocate bounce buffers with GFP_NOWAIT 2014-08-04 15:23:03 -07:00
bset.h bcache: fix typo in bch_bkey_equal_header 2014-08-04 15:23:03 -07:00
btree.c bcache: Add a cond_resched() call to gc 2015-12-30 20:23:06 -07:00
btree.h bcache: try to set b->parent properly 2014-08-04 15:23:04 -07:00
closure.c bcache: Really show state of work pending bit 2015-11-06 15:06:05 +01:00
closure.h block: add a bi_error field to struct bio 2015-07-29 08:55:15 -06:00
debug.c bcache: Convert debug code to btree_keys 2014-01-08 13:05:13 -08:00
debug.h bcache: Convert debug code to btree_keys 2014-01-08 13:05:13 -08:00
extents.c bcache: Fix a journal replay bug 2014-08-04 15:23:02 -07:00
extents.h bcache: Fix a journal replay bug 2014-08-04 15:23:02 -07:00
io.c bcache: remove driver private bio splitting code 2015-08-13 12:31:40 -06:00
journal.c bcache: remove driver private bio splitting code 2015-08-13 12:31:40 -06:00
journal.h bcache: Fix a shutdown bug 2014-02-25 18:42:49 -08:00
Kconfig bcache: Kill dead cgroup code 2014-03-18 12:22:35 -07:00
Makefile bcache: Abstract out stuff needed for sorting 2014-01-08 13:05:12 -08:00
movinggc.c block: add a bi_error field to struct bio 2015-07-29 08:55:15 -06:00
request.c block: change ->make_request_fn() and users to return a queue cookie 2015-11-07 10:40:46 -07:00
request.h bcache: Kill dead cgroup code 2014-03-18 12:22:35 -07:00
stats.c bcache: Kill dead cgroup code 2014-03-18 12:22:35 -07:00
stats.h bcache: Break up struct search 2013-11-10 21:56:32 -08:00
super.c bcache: cleaned up error handling around register_cache() 2016-03-08 09:19:08 -07:00
sysfs.c bcache: remove nested function usage 2014-03-18 12:39:28 -07:00
sysfs.h bcache: Don't export utility code, prefix with bch_ 2013-03-28 12:50:55 -06:00
trace.c bcache: Better alloc tracepoints 2014-03-18 12:22:35 -07:00
util.c md: more open-coded offset_in_page() 2016-01-04 10:29:12 -05:00
util.h bcache: remove driver private bio splitting code 2015-08-13 12:31:40 -06:00
writeback.c bcache: Change refill_dirty() to always scan entire disk if necessary 2015-12-30 20:23:16 -07:00
writeback.h bcache: prevent crash on changing writeback_running 2015-12-30 20:23:14 -07:00