diff options
author | Michael Knudsen <mk@cvs.openbsd.org> | 2011-06-17 07:06:48 +0000 |
---|---|---|
committer | Michael Knudsen <mk@cvs.openbsd.org> | 2011-06-17 07:06:48 +0000 |
commit | 588580a3636f1d2f89071c40a24811393a93accc (patch) | |
tree | fe14f36309c4c36297658840fbee97ea66114ab6 /sys/dev/usb/umidi.c | |
parent | f54f5c33e3808aca4c742c69b64f7a9619f240cb (diff) |
M_WAITOK cleanup of two cases:
1) Allocating with M_WAITOK, checking for NULL, and calling panic() is
pointless (malloc() will panic if it can't allocate) so remove the check
and the call.
2) Allocating with M_WAITOK, checking for NULL, and then gracefully
handling failure to allocate is pointless. Instead also pass M_CANFAIL
so malloc() doesn't panic so we can actually handle it gracefully.
1) was done using Coccinelle.
Input from oga.
ok miod.
Diffstat (limited to 'sys/dev/usb/umidi.c')
-rw-r--r-- | sys/dev/usb/umidi.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/sys/dev/usb/umidi.c b/sys/dev/usb/umidi.c index 78ae450a612..82fb2e1c50a 100644 --- a/sys/dev/usb/umidi.c +++ b/sys/dev/usb/umidi.c @@ -1,4 +1,4 @@ -/* $OpenBSD: umidi.c,v 1.28 2011/01/25 20:03:36 jakemsr Exp $ */ +/* $OpenBSD: umidi.c,v 1.29 2011/06/17 07:06:47 mk Exp $ */ /* $NetBSD: umidi.c,v 1.16 2002/07/11 21:14:32 augustss Exp $ */ /* * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -456,7 +456,7 @@ alloc_all_endpoints_fixed_ep(struct umidi_softc *sc) sc->sc_endpoints = malloc(sizeof(*sc->sc_out_ep)* (sc->sc_out_num_endpoints+ sc->sc_in_num_endpoints), - M_USBDEV, M_WAITOK); + M_USBDEV, M_WAITOK | M_CANFAIL); if (!sc->sc_endpoints) { return USBD_NOMEM; } @@ -599,7 +599,7 @@ alloc_all_endpoints_yamaha(struct umidi_softc *sc) sc->sc_endpoints = malloc(sizeof(struct umidi_endpoint)* (sc->sc_out_num_endpoints+ sc->sc_in_num_endpoints), - M_USBDEV, M_WAITOK); + M_USBDEV, M_WAITOK | M_CANFAIL); if (!sc->sc_endpoints) return USBD_NOMEM; if (sc->sc_out_num_endpoints) { @@ -641,7 +641,7 @@ alloc_all_endpoints_genuine(struct umidi_softc *sc) interface_desc = usbd_get_interface_descriptor(sc->sc_iface); num_ep = interface_desc->bNumEndpoints; sc->sc_endpoints = p = malloc(sizeof(struct umidi_endpoint) * num_ep, - M_USBDEV, M_WAITOK); + M_USBDEV, M_WAITOK | M_CANFAIL); if (!p) return USBD_NOMEM; @@ -734,7 +734,7 @@ alloc_all_jacks(struct umidi_softc *sc) sc->sc_jacks = malloc(sizeof(*sc->sc_out_jacks)*(sc->sc_in_num_jacks+ sc->sc_out_num_jacks), - M_USBDEV, M_WAITOK); + M_USBDEV, M_WAITOK | M_CANFAIL); if (!sc->sc_jacks) return USBD_NOMEM; sc->sc_out_jacks = @@ -975,7 +975,7 @@ alloc_all_mididevs(struct umidi_softc *sc, int nmidi) { sc->sc_num_mididevs = nmidi; sc->sc_mididevs = malloc(sizeof(*sc->sc_mididevs)*nmidi, M_USBDEV, - M_WAITOK | M_ZERO); + M_WAITOK | M_CANFAIL | M_ZERO); if (!sc->sc_mididevs) return USBD_NOMEM; |