dm log userspace: fix memory leak in dm_ulog_tfr_init failure path
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Wed, 1 Oct 2014 20:58:35 +0000 (22:58 +0200)
committerMike Snitzer <snitzer@redhat.com>
Mon, 6 Oct 2014 00:03:38 +0000 (20:03 -0400)
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 <khoroshilov@ispras.ru>
Reviewed-by: Jonathan Brassow <jbrassow@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
drivers/md/dm-log-userspace-transfer.c

index b428c0ae63d5d1e3c173cd0afe9b04072f786415..39ad9664d39731022796430b0a3a30b7a8464898 100644 (file)
@@ -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;
        }