[PATCH] btrfs-progs: handle memory allocation error in cmd_device_stats

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Resolves-coverity-id: 1359012
Signed-off-by: David Sterba <dsterba@xxxxxxxx>
---
 cmds-device.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/cmds-device.c b/cmds-device.c
index 5c0040c4f2ab..1c886ad58939 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);
 			}
-- 
2.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux