Skip to contentSkip to conversation

btrfs-progs: handle memory allocation error in cmd_device_stats

PATCH New David Sterba 1 participant 1 message May 2, 2016 Btrfs file system

lore
Share & tools
lore

David Sterba

author maintainer
#0 lore raw

PATCH 1/1 btrfs-progs: handle memory allocation error in cmd_device_stats

Resolves-coverity-id: 1359012

---
 cmds-device.c | 4 ++++
 1 file changed, 4 insertions(+)
cmds-device.c +4 -0
index 5c0040c4f2ab..1c886ad58939 100644
@@ -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);
 			}
Signature · 1 line
2.7.1