]> www.infradead.org Git - users/jedix/linux-maple.git/commit
bcache: cleaned up error handling around register_cache()
authorEric Wheeler <git@linux.ewheeler.net>
Fri, 26 Feb 2016 22:33:56 +0000 (14:33 -0800)
committerChuck Anderson <chuck.anderson@oracle.com>
Thu, 26 May 2016 22:46:20 +0000 (15:46 -0700)
commit58099098790f7e4b10fc832fa8cafbc44890fd88
tree205afe46d0d69d9fb140d1abd5be531de87550fb
parent32af85557d8d214e77bb144d4705194b37368f01
bcache: cleaned up error handling around register_cache()

Orabug: 23331096

[ Upstream commit 9b299728ed777428b3908ac72ace5f8f84b97789 ]

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>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
(cherry picked from commit 0e6555443a206655885bc4126d9a3a0e2d9d17a3)

Signed-off-by: Dan Duval <dan.duval@oracle.com>
drivers/md/bcache/super.c