summaryrefslogtreecommitdiff
path: root/lib/libmtd_legacy.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-10-01 13:13:10 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-10-02 17:19:44 +0300
commitb8bbd73bb5bd0b1f5f2c6a3441486d69a45cc79c (patch)
tree4b8ce33411f6be72e208e78c6a44d481fddc5e74 /lib/libmtd_legacy.c
parent2e6f057227fb60465bd76876cf783ad56561930c (diff)
libmtd: make malloc failures fatal
This converts libmtd to the common xalloc helpers and in doing so, makes memory allocation failures fatal rather than returning an error to the caller. I think this is acceptable behavior. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'lib/libmtd_legacy.c')
-rw-r--r--lib/libmtd_legacy.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/libmtd_legacy.c b/lib/libmtd_legacy.c
index 3d129c1..7488275 100644
--- a/lib/libmtd_legacy.c
+++ b/lib/libmtd_legacy.c
@@ -75,12 +75,7 @@ static int proc_parse_start(struct proc_parse_info *pi)
if (fd == -1)
return -1;
- pi->buf = malloc(PROC_MTD_MAX_LEN);
- if (!pi->buf) {
- sys_errmsg("cannot allocate %d bytes of memory",
- PROC_MTD_MAX_LEN);
- goto out_close;
- }
+ pi->buf = xmalloc(PROC_MTD_MAX_LEN);
ret = read(fd, pi->buf, PROC_MTD_MAX_LEN);
if (ret == -1) {
@@ -103,7 +98,6 @@ static int proc_parse_start(struct proc_parse_info *pi)
out_free:
free(pi->buf);
-out_close:
close(fd);
return -1;
}