Skip to content

Commit

Permalink
Removing condition that will never be met after calls xmalloc and xre…
Browse files Browse the repository at this point in the history
…alloc

Hi,

Looking in the kexec-tools code I found these conditions that
seems will never be met. Not sure if that was intentional for explicitity,
if it was the case, please disconsider this patch.

xmalloc and xrealloc when fails calls die() that calls exit(1).
Checks for if(!memory) after they are called will never be met that
condition, since the process will be exited after an allocation fail.

Signed-off-by: Leonidas S. Barbosa <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
  • Loading branch information
kirotawa authored and horms committed Apr 1, 2020
1 parent 618799e commit cbbee58
Showing 1 changed file with 0 additions and 12 deletions.
12 changes: 0 additions & 12 deletions kexec/arch/arm/kexec-zImage-arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ int atag_arm_load(struct kexec_info *info, unsigned long base,
struct tag *params;

buf = xmalloc(getpagesize());
if (!buf) {
fprintf(stderr, "Compiling ATAGs: out of memory\n");
return -1;
}

memset(buf, 0xff, getpagesize());
params = (struct tag *)buf;

Expand Down Expand Up @@ -315,8 +310,6 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
dtb_size += fdt_node_len(node_name);
fdt_set_totalsize(dtb_buf, dtb_size);
dtb_buf = xrealloc(dtb_buf, dtb_size);
if (dtb_buf == NULL)
die("xrealloc failed\n");
off = fdt_add_subnode(dtb_buf, parentoffset, node_name);
}

Expand All @@ -340,8 +333,6 @@ static int setup_dtb_prop(char **bufp, off_t *sizep, int parentoffset,
if (fdt_totalsize(dtb_buf) < dtb_size) {
fdt_set_totalsize(dtb_buf, dtb_size);
dtb_buf = xrealloc(dtb_buf, dtb_size);
if (dtb_buf == NULL)
die("xrealloc failed\n");
}

if (fdt_setprop(dtb_buf, off, prop_name,
Expand Down Expand Up @@ -616,9 +607,6 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len,
uint64_t start, end;

modified_cmdline = xmalloc(COMMAND_LINE_SIZE);
if (!modified_cmdline)
return -1;

memset(modified_cmdline, '\0', COMMAND_LINE_SIZE);

if (command_line) {
Expand Down

0 comments on commit cbbee58

Please sign in to comment.