| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | [PATCH 01/11] xfsprogs: xfs_io: fix a memory leak in imap_f |
| From: | Vivek Trivedi <t.vivek@xxxxxxxxxxx> |
| Date: | Wed, 02 Dec 2015 16:49:17 +0530 |
| Cc: | a.sahrawat@xxxxxxxxxxx, pankaj.m@xxxxxxxxxxx, Vivek Trivedi <t.vivek@xxxxxxxxxxx> |
| Delivered-to: | xfs@xxxxxxxxxxx |
| Dlp-filter: | Pass |
| In-reply-to: | <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> |
| References: | <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> |
add NULL check for malloc return and free allocated memory in
return path in imap_f
Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
---
io/imap.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/io/imap.c b/io/imap.c
index 34901cb..6ed98eb 100644
--- a/io/imap.c
+++ b/io/imap.c
@@ -39,6 +39,8 @@ imap_f(int argc, char **argv)
nent = atoi(argv[1]);
t = malloc(nent * sizeof(*t));
+ if (!t)
+ return 0;
bulkreq.lastip = &last;
bulkreq.icount = nent;
@@ -46,8 +48,10 @@ imap_f(int argc, char **argv)
bulkreq.ocount = &count;
while (xfsctl(file->name, file->fd, XFS_IOC_FSINUMBERS, &bulkreq) == 0)
{
- if (count == 0)
+ if (count == 0) {
+ free(t);
return 0;
+ }
for (i = 0; i < count; i++) {
printf(_("ino %10llu count %2d mask %016llx\n"),
(unsigned long long)t[i].xi_startino,
@@ -55,6 +59,7 @@ imap_f(int argc, char **argv)
(unsigned long long)t[i].xi_allocmask);
}
}
+ free(t);
perror("xfsctl(XFS_IOC_FSINUMBERS)");
exitcode = 1;
return 0;
--
1.7.9.5
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | [PATCH 02/11] xfsprogs: fix integer overflow in xlog_find_verify_cycle, Vivek Trivedi |
|---|---|
| Next by Date: | [PATCH 03/11] xfsprogs: mkfs: fix unintentional integer overflow, Vivek Trivedi |
| Previous by Thread: | Re: [PATCH 02/11] xfsprogs: fix integer overflow in xlog_find_verify_cycle, Dave Chinner |
| Next by Thread: | Re: [PATCH 01/11] xfsprogs: xfs_io: fix a memory leak in imap_f, Eric Sandeen |
| Indexes: | [Date] [Thread] [Top] [All Lists] |