qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n)
@ 2018-11-27 13:04 Greg Kurz
  2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 1/9] target/ppc: use g_new(T, n) instead " Greg Kurz
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Greg Kurz @ 2018-11-27 13:04 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-ppc, David Gibson, Edgar E. Iglesias

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.

--
Greg

---

Greg Kurz (9):
      target/ppc: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      spapr: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      ppc405_boards: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      ppc405_uc: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      ppc440_bamboo: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      sam460ex: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      virtex_ml507: use g_new(T, n) instead of g_malloc(sizeof(T) * n)
      mac_newworld: simplify IRQ wiring
      e500: simplify IRQ wiring


 hw/ppc/e500.c                   |   18 ++++++++----------
 hw/ppc/mac_newworld.c           |   30 +++++++++++++-----------------
 hw/ppc/ppc405_boards.c          |    4 ++--
 hw/ppc/ppc405_uc.c              |    4 ++--
 hw/ppc/ppc440_bamboo.c          |    5 ++---
 hw/ppc/sam460ex.c               |    2 +-
 hw/ppc/spapr_iommu.c            |    2 +-
 hw/ppc/spapr_vio.c              |    2 +-
 hw/ppc/virtex_ml507.c           |    2 +-
 include/hw/ppc/openpic.h        |    2 ++
 target/ppc/translate_init.inc.c |    6 +++---
 11 files changed, 36 insertions(+), 41 deletions(-)

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2018-11-28  0:31 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-27 13:04 [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n) Greg Kurz
2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 1/9] target/ppc: use g_new(T, n) instead " Greg Kurz
2018-11-27 13:42   ` Philippe Mathieu-Daudé
2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 2/9] spapr: " Greg Kurz
2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 3/9] ppc405_boards: " Greg Kurz
2018-11-27 13:41   ` Philippe Mathieu-Daudé
2018-11-27 13:52     ` Greg Kurz
2018-11-27 14:03       ` Philippe Mathieu-Daudé
2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 4/9] ppc405_uc: " Greg Kurz
2018-11-27 13:42   ` Philippe Mathieu-Daudé
2018-11-27 13:05 ` [Qemu-devel] [PATCH for-4.0 5/9] ppc440_bamboo: " Greg Kurz
2018-11-27 13:43   ` Philippe Mathieu-Daudé
2018-11-27 14:01   ` Edgar E. Iglesias
2018-11-27 13:06 ` [Qemu-devel] [PATCH for-4.0 6/9] sam460ex: " Greg Kurz
2018-11-27 13:49   ` Philippe Mathieu-Daudé
2018-11-27 13:06 ` [Qemu-devel] [PATCH for-4.0 7/9] virtex_ml507: " Greg Kurz
2018-11-27 13:47   ` Philippe Mathieu-Daudé
2018-11-27 14:00   ` Edgar E. Iglesias
2018-11-27 13:06 ` [Qemu-devel] [PATCH for-4.0 8/9] mac_newworld: simplify IRQ wiring Greg Kurz
2018-11-27 13:06 ` [Qemu-devel] [PATCH for-4.0 9/9] e500: " Greg Kurz
2018-11-27 13:16 ` [Qemu-devel] [PATCH for-4.0 0/9] ppc: get rid of g_malloc(sizeof(T) * n) Eric Blake
2018-11-27 13:23   ` Greg Kurz
2018-11-27 22:54 ` David Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).