add NULL check for malloc return and free allocated memory in
return path in imap_f
[dchinner: changed to error stack]
Signed-off-by: Vivek Trivedi <t.vivek@samsung.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
nent = atoi(argv[1]);
t = malloc(nent * sizeof(*t));
+ if (!t)
+ return 0;
bulkreq.lastip = &last;
bulkreq.icount = nent;
while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0) {
if (count == 0)
- return 0;
+ goto out_free;
for (i = 0; i < count; i++) {
printf(_("ino %10llu count %2d mask %016llx\n"),
(unsigned long long)t[i].xi_startino,
}
perror("xfsctl(XFS_IOC_FSINUMBERS)");
exitcode = 1;
+out_free:
+ free(t);
return 0;
}