aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-device.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-05-02 15:03:24 +0200
committerDavid Sterba <dsterba@suse.com>2016-05-02 15:03:24 +0200
commit5fcc6e93f05182c598c389ce2c4b9c68a385521f (patch)
tree3c3a26fc290b5e01ad15f9b03cefe70dd2cf286d /cmds-device.c
parent0121270a799df52dab8de852b326ebdaf05e19c9 (diff)
downloadbtrfs-progs-5fcc6e93f05182c598c389ce2c4b9c68a385521f.tar.gz
btrfs-progs-5fcc6e93f05182c598c389ce2c4b9c68a385521f.tar.xz
btrfs-progs-5fcc6e93f05182c598c389ce2c4b9c68a385521f.zip
btrfs-progs: handle memory allocation error in cmd_device_stats
Resolves-coverity-id: 1359012 Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-device.c')
-rw-r--r--cmds-device.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/cmds-device.c b/cmds-device.c
index 5c0040c..1c886ad 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -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);
}