| To: | xfs@xxxxxxxxxxx |
|---|---|
| Subject: | Re: [PATCH 01/11] xfsprogs: xfs_io: fix a memory leak in imap_f |
| From: | Eric Sandeen <sandeen@xxxxxxxxxxx> |
| Date: | Wed, 2 Dec 2015 11:55:06 -0600 |
| Delivered-to: | xfs@xxxxxxxxxxx |
| In-reply-to: | <1449055167-19936-2-git-send-email-t.vivek@xxxxxxxxxxx> |
| References: | <1449055167-19936-1-git-send-email-t.vivek@xxxxxxxxxxx> <1449055167-19936-2-git-send-email-t.vivek@xxxxxxxxxxx> |
| User-agent: | Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 |
On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> add NULL check for malloc return and free allocated memory in
> return path in imap_f
>
> Signed-off-by: Vivek Trivedi <t.vivek@xxxxxxxxxxx>
Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>
> ---
> 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;
>
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||
| Previous by Date: | Re: Which xfsprogs version to which kernel version, Arkadiusz MiÅkiewicz |
|---|---|
| Next by Date: | Re: [PATCH 02/11] xfsprogs: fix integer overflow in xlog_find_verify_cycle, Eric Sandeen |
| Previous by Thread: | [PATCH 01/11] xfsprogs: xfs_io: fix a memory leak in imap_f, Vivek Trivedi |
| Next by Thread: | [PATCH 03/11] xfsprogs: mkfs: fix unintentional integer overflow, Vivek Trivedi |
| Indexes: | [Date] [Thread] [Top] [All Lists] |