OSDN Git Service

staging: lustre: lustre: obdclass: obd_mount.c: Fix NULL dereference
authorKumar Amit Mehta <gmate.amit@gmail.com>
Mon, 26 Jan 2015 16:52:22 +0000 (17:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 28 Jan 2015 18:52:05 +0000 (10:52 -0800)
OBD_ALLOC_PTR(uuid) invokes kmalloc, which may return NULL. This fix
adds a check before dereferencing such pointer.

Signed-off-by: Kumar Amit Mehta <gmate.amit@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/obd_mount.c

index 4f39cde..3c0c910 100644 (file)
@@ -376,6 +376,11 @@ int lustre_start_mgc(struct super_block *sb)
 
        /* Random uuid for MGC allows easier reconnects */
        OBD_ALLOC_PTR(uuid);
+       if (!uuid) {
+               rc = -ENOMEM;
+               goto out_free;
+       }
+
        ll_generate_random_uuid(uuidc);
        class_uuid_unparse(uuidc, uuid);