[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc.
From: |
Peter Maydell |
Subject: |
Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc. |
Date: |
Wed, 26 Jul 2023 10:43:30 +0100 |
(Something went wrong with the quoting in your email. I've
fixed it up.)
On Wed, 26 Jul 2023 at 05:38, <dinglimin@cmss.chinamobile.com> wrote:
> Peter Maydell wrote:
> > The third part here, is that g_malloc() does not ever
> > fail -- it will abort() on out of memory. However
> > the code here is still handling g_malloc() returning NULL.
> > The equivalent for "we expect this might fail" (which we want
> > here, because the guest is passing us the length of memory
> > to try to allocate) is g_try_malloc().
> g_malloc() is preferred more than g_try_* functions, which return NULL on
> error,
> when the size of the requested allocation is small.
> This is because allocating few bytes should not be a problem in a healthy
> system.
This is true. But in this particular case we cannot be sure
that the size of the allocation is small, because the size
is controlled by the guest. So we want g_try_malloc().
thanks
-- PMM
- [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/25
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Michael Tokarev, 2023/07/25
- [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/25
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Michael Tokarev, 2023/07/25
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Peter Maydell, 2023/07/25
- 回复: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/26
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc.,
Peter Maydell <=
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Richard Henderson, 2023/07/26
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Peter Maydell, 2023/07/27
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Daniel P . Berrangé, 2023/07/27
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Richard Henderson, 2023/07/27
- [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/28
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Peter Maydell, 2023/07/28
- [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/28
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Peter Maydell, 2023/07/28
- Re: [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., Peter Maydell, 2023/07/28
- [PATCH] semihosting/uaccess.c: Replaced a malloc call with g_malloc., dinglimin, 2023/07/26