]> sourceware.org Git - dm.git/commitdiff
Fix uuid kmalloc.
authorAlasdair Kergon <agk@redhat.com>
Mon, 18 Mar 2002 18:40:35 +0000 (18:40 +0000)
committerAlasdair Kergon <agk@redhat.com>
Mon, 18 Mar 2002 18:40:35 +0000 (18:40 +0000)
kernel/common/dm.c.in

index 599dde89aa951c8f236ba376629267562dd6d7a7..dfb4cbedcb1e11827436d3858b98b173359606b4 100644 (file)
@@ -732,6 +732,7 @@ static struct mapped_device *alloc_dev(const char *name, const char *uuid,
                                       int minor)
 {
        struct mapped_device *md = kmalloc(sizeof(*md), GFP_KERNEL);
+       int len;
 
        if (!md) {
                DMWARN("unable to allocate device, out of memory.");
@@ -757,14 +758,14 @@ static struct mapped_device *alloc_dev(const char *name, const char *uuid,
        md->name[sizeof(md->name) - 1] = '\0';
 
        if (*uuid) {
-               if (!(md->uuid = kmalloc(strnlen(uuid, DM_UUID_LEN) + 1,
-                                        GFP_KERNEL))) {
+               len = strnlen(uuid, DM_UUID_LEN) + 1;
+               if (!(md->uuid = kmalloc(len, GFP_KERNEL))) {
                        DMWARN("unable to allocate uuid - out of memory.");
                        return NULL;
                }
 
-               strncpy(md->uuid, uuid, DM_UUID_LEN - 1);
-               md->uuid[DM_UUID_LEN] = '\0';
+               strncpy(md->uuid, uuid, len - 1);
+               md->uuid[len - 1] = '\0';
        }
 
        init_waitqueue_head(&md->wait);
This page took 0.025544 seconds and 5 git commands to generate.