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 4f39cdee1b5c7a838c6eca6729c0b9972aa60dc2..3c0c9109cefd31ffd6946977cbfc2933272cdc3d 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);