[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-ppc] [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc
From: |
Greg Kurz |
Subject: |
Re: [Qemu-ppc] [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n) |
Date: |
Tue, 27 Nov 2018 14:23:37 +0100 |
On Tue, 27 Nov 2018 07:16:44 -0600
Eric Blake <address@hidden> wrote:
> On 11/27/18 7:04 AM, Greg Kurz wrote:
> > As explained in HACKING, the g_malloc(sizeof(T) * n) construct is unsafe
> > because it can't detect multiplication overflowing size_t and doesn't
> > allow type checking.
> >
> > It appears to be used in a bunch of places though:
> >
> > $ git grep -E 'malloc.*sizeof' | grep ' \* ' | wc -l
> > 101
> >
> > This series fixes the ppc target and ppc machine code. The changes are
> > mostly trivial. Only the mac99 and e500 machines required some more work
> > that should be reviewed carefully, as it was only compile-tested.
>
> Did you do this all manually, or did you try to use Coccinelle? Hmm -
> we have a Coccinelle script for this mentioned in commit b45c03f (most
> recently reused in bdd81add) - but it is not yet in scripts/coccinelle/.
> Maybe that would be worth doing now.
>
I did that manually because I didn't know about Markus's Coccinelle
script... Also, I've only fixed the case involving a multiplication,
since HACKING says "g_malloc(sizeof(*v)) are acceptable".
I'll have a look at adding the script in scripts/coccinelle/.
Cheers,
--
Greg
- Re: [Qemu-ppc] [Qemu-devel] [PATCH for-4.0 5/9] ppc440_bamboo: use g_new(T, n) instead of g_malloc(sizeof(T) * n), (continued)
- [Qemu-ppc] [PATCH for-4.0 6/9] sam460ex: use g_new(T, n) instead of g_malloc(sizeof(T) * n), Greg Kurz, 2018/11/27
- [Qemu-ppc] [PATCH for-4.0 7/9] virtex_ml507: use g_new(T, n) instead of g_malloc(sizeof(T) * n), Greg Kurz, 2018/11/27
- [Qemu-ppc] [PATCH for-4.0 8/9] mac_newworld: simplify IRQ wiring, Greg Kurz, 2018/11/27
- [Qemu-ppc] [PATCH for-4.0 9/9] e500: simplify IRQ wiring, Greg Kurz, 2018/11/27
- Re: [Qemu-ppc] [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n), Eric Blake, 2018/11/27
- Re: [Qemu-ppc] [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n),
Greg Kurz <=
- Re: [Qemu-ppc] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n), David Gibson, 2018/11/27