From 9f8d9a2c5fb8443b41183545c682189d8743923c Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Mon, 20 Jul 2015 10:52:28 -0400 Subject: [PATCH] debugfs: handle out of memory condition If malloc fails, properly handle the error condition. Signed-off-by: Tobias Stoeckmann Signed-off-by: Theodore Ts'o --- debugfs/extent_inode.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/debugfs/extent_inode.c b/debugfs/extent_inode.c index 8b22f5e..c7a92a7 100644 --- a/debugfs/extent_inode.c +++ b/debugfs/extent_inode.c @@ -97,6 +97,11 @@ void do_extent_open(int argc, char *argv[]) orig_prompt = ss_get_prompt(sci_idx); extent_prompt = malloc(strlen(orig_prompt) + 32); + if (extent_prompt == NULL) { + com_err(argv[1], retval, "out of memory"); + return; + } + strcpy(extent_prompt, orig_prompt); cp = strchr(extent_prompt, ':'); if (cp) -- 1.8.3.1