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:06:40 +0000 (06:06 +0800)
commitf8cf1124a8f6cdd4ebc834ec3d848508e229e1d4
treeb7b73a6eca1986a2f32e0b607619893c0195f54b
parent6ee1df3bff435d169d0ab93420bd02b4f9392e66
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