All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ahmed Abouzied <email@aabouzied.com>
To: qemu-qemu-trivial@nongnu.org
Cc: Ahmed Abouzied <email@aabouzied.com>,
	jsnow@redhat.com, qemu-devel@nongnu.org
Subject: [PATCH] linux-user/syscall.c: malloc to g_try_malloc
Date: Tue,  4 Jan 2022 16:38:41 +0200	[thread overview]
Message-ID: <20220104143841.25116-1-email@aabouzied.com> (raw)

Use g_try_malloc instead of malloc to alocate the target ifconfig.
Also replace the corresponding free with g_free.

Signed-off-by: Ahmed Abouzied <email@aabouzied.com>
---

Hello, 

I noticed that there was a `malloc` call in this file. It seems that it
was added by the commit 22e4a267 (3 years ago) which was after the commit
0e173b24 (6 years ago) that replaced malloc calls with glib alternative calls.

There is no issue for this on Gitlab. Should I have created an issue
first? 

Best regards,

 linux-user/syscall.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 56a3e17183..715f9430e1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4867,7 +4867,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp,
              * We can't fit all the extents into the fixed size buffer.
              * Allocate one that is large enough and use it instead.
              */
-            host_ifconf = malloc(outbufsz);
+            host_ifconf = g_try_malloc(outbufsz);
             if (!host_ifconf) {
                 return -TARGET_ENOMEM;
             }
@@ -4915,7 +4915,7 @@ static abi_long do_ioctl_ifconf(const IOCTLEntry *ie, uint8_t *buf_temp,
     }
 
     if (free_buf) {
-        free(host_ifconf);
+        g_free(host_ifconf);
     }
 
     return ret;
-- 
2.25.1



             reply	other threads:[~2022-01-04 14:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-04 14:38 Ahmed Abouzied [this message]
2022-01-05 10:26 ` [PATCH] linux-user/syscall.c: malloc to g_try_malloc Laurent Vivier
     [not found]   ` <CANL98e9RO38rmP8oSmEcoop3Pr_qC741Om91Bw9FQxAZcqf2QQ@mail.gmail.com>
2022-01-06 14:05     ` Byte Sized task (was Re: [PATCH] linux-user/syscall.c: malloc to g_try_malloc) Laurent Vivier
2022-01-10 19:42       ` John Snow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220104143841.25116-1-email@aabouzied.com \
    --to=email@aabouzied.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-qemu-trivial@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.