]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rbd: don't leak parent_spec in rbd_dev_probe_parent()
authorIlya Dryomov <idryomov@gmail.com>
Sun, 11 Oct 2015 17:38:00 +0000 (19:38 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Nov 2015 22:37:34 +0000 (14:37 -0800)
commitafbd0c41b3594241d08c43b6cbf6db042f4f4b78
treeb34d96393df21666b85c1d708b7117d51963b12f
parent960811cc41e99b9ac2d87f18aef2c3c94ea793bd
rbd: don't leak parent_spec in rbd_dev_probe_parent()

commit 1f2c6651f69c14d0d3a9cfbda44ea101b02160ba upstream.

Currently we leak parent_spec and trigger a "parent reference
underflow" warning if rbd_dev_create() in rbd_dev_probe_parent() fails.
The problem is we take the !parent out_err branch and that only drops
refcounts; parent_spec that would've been freed had we called
rbd_dev_unparent() remains and triggers rbd_warn() in
rbd_dev_parent_put() - at that point we have parent_spec != NULL and
parent_ref == 0, so counter ends up being -1 after the decrement.

Redo rbd_dev_probe_parent() to fix this.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/rbd.c