Eric Wheeler d9dc1702b2 bcache: register_bcache(): call blkdev_put() when cache_alloc() fails
register_cache() is supposed to return an error string on error so that
register_bcache() will will blkdev_put and cleanup other user counters,
but it does not set 'char *err' when cache_alloc() fails (eg, due to
memory pressure) and thus register_bcache() performs no cleanup.

register_bcache() <----------\  <- no jump to err_close, no blkdev_put()
   |                         |
   +->register_cache()       |  <- fails to set char *err
         |                   |
         +->cache_alloc() ---/  <- returns error

This patch sets `char *err` for this failure case so that register_cache()
will cause register_bcache() to correctly jump to err_close and do
cleanup.  This was tested under OOM conditions that triggered the bug.

Signed-off-by: Eric Wheeler <bcache@linux.ewheeler.net>
Cc: Kent Overstreet <kent.overstreet@gmail.com>
Cc: stable@vger.kernel.org
2016-08-18 20:28:23 -07:00
..
2016-06-07 13:41:38 -06:00
2014-08-04 15:23:04 -07:00
2016-07-05 11:34:49 -06:00
2016-07-05 11:34:49 -06:00
2016-06-07 13:41:38 -06:00
2014-08-04 15:23:02 -07:00
2014-08-04 15:23:02 -07:00
2014-02-25 18:42:49 -08:00
2014-03-18 12:22:35 -07:00
2016-06-07 13:41:38 -06:00
2016-08-07 14:41:02 -06:00
2014-03-18 12:22:35 -07:00
2014-03-18 12:22:35 -07:00
2013-11-10 21:56:32 -08:00
2014-03-18 12:39:28 -07:00
2014-03-18 12:22:35 -07:00
2016-01-04 10:29:12 -05:00
2016-06-07 13:41:38 -06:00
2016-08-07 14:41:02 -06:00