btrfs-progs: handle memory allocation error in cmd_device_stats
authorDavid Sterba <dsterba@suse.com>
Mon, 2 May 2016 13:03:24 +0000 (15:03 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 2 May 2016 13:03:24 +0000 (15:03 +0200)
Resolves-coverity-id: 1359012
Signed-off-by: David Sterba <dsterba@suse.com>
cmds-device.c

index 5c0040c..1c886ad 100644 (file)
@@ -450,6 +450,10 @@ static int cmd_device_stats(int argc, char **argv)
                        /* No path when device is missing. */
                        if (!canonical_path) {
                                canonical_path = malloc(32);
+                               if (!canonical_path) {
+                                       error("not enough memory for path buffer");
+                                       goto out;
+                               }
                                snprintf(canonical_path, 32,
                                         "devid:%llu", args.devid);
                        }