From: Alexey Khoroshilov Date: Wed, 1 Oct 2014 20:58:35 +0000 (+0200) Subject: dm log userspace: fix memory leak in dm_ulog_tfr_init failure path X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=56ec16cb1e1ce46354de8511eef962a417c32c92;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git dm log userspace: fix memory leak in dm_ulog_tfr_init failure path If cn_add_callback() fails in dm_ulog_tfr_init(), it does not deallocate prealloced memory but calls cn_del_callback(). Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Reviewed-by: Jonathan Brassow Signed-off-by: Mike Snitzer Cc: stable@vger.kernel.org --- diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c index b428c0ae63d5..39ad9664d397 100644 --- a/drivers/md/dm-log-userspace-transfer.c +++ b/drivers/md/dm-log-userspace-transfer.c @@ -272,7 +272,7 @@ int dm_ulog_tfr_init(void) r = cn_add_callback(&ulog_cn_id, "dmlogusr", cn_ulog_callback); if (r) { - cn_del_callback(&ulog_cn_id); + kfree(prealloced_cn_msg); return r; }