xen-blkback: do not leak mode property
authorJan Beulich <JBeulich@suse.com>
Thu, 20 Dec 2012 10:31:11 +0000 (10:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 3 Mar 2013 22:09:04 +0000 (06:09 +0800)
commit975398374dac831d5d5c2825615c489aee24ea3a
tree1a4e120177b9d1ebc0847452ecb65f3ddcf0e781
parentad315127433dc9a8147e7f6b43f21b3d0061003a
xen-blkback: do not leak mode property

commit 9d092603cc306ee6edfe917bf9ab8beb5f32d7bc upstream.

"be->mode" is obtained from xenbus_read(), which does a kmalloc() for
the message body. The short string is never released, so do it along
with freeing "be" itself, and make sure the string isn't kept when
backend_changed() doesn't complete successfully (which made it
desirable to slightly re-structure that function, so that the error
cleanup can be done in one place).

Reported-by: Olaf Hering <olaf@aepfle.de>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/block/xen-blkback/xenbus.c