diff options
| author | chs <chs@NetBSD.org> | 2019-10-01 18:00:07 +0000 |
|---|---|---|
| committer | chs <chs@NetBSD.org> | 2019-10-01 18:00:07 +0000 |
| commit | 68befe26cc9d9b793852833794a256113bf7caa6 (patch) | |
| tree | 6ddf33f9c9e75114697f2a7c9005a614417ecbb9 /sys/dev | |
| parent | e3b5e434bf80b327067ef158330762d70b75396e (diff) | |
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/acpi/acpi_srat.c | 27 | ||||
| -rw-r--r-- | sys/dev/hyperv/hvkbd.c | 26 | ||||
| -rw-r--r-- | sys/dev/hyperv/hvs.c | 19 | ||||
| -rw-r--r-- | sys/dev/hyperv/if_hvn.c | 12 | ||||
| -rw-r--r-- | sys/dev/hyperv/vmbusic.c | 6 | ||||
| -rw-r--r-- | sys/dev/i2c/ihidev.c | 12 | ||||
| -rw-r--r-- | sys/dev/i2c/sdtemp.c | 11 | ||||
| -rw-r--r-- | sys/dev/iscsi/iscsi_main.c | 9 | ||||
| -rw-r--r-- | sys/dev/nand/nandemulator.c | 11 | ||||
| -rw-r--r-- | sys/dev/pci/arcmsr.c | 9 | ||||
| -rw-r--r-- | sys/dev/pci/if_vioif.c | 31 | ||||
| -rw-r--r-- | sys/dev/pci/pciconf.c | 11 | ||||
| -rw-r--r-- | sys/dev/pci/virtio.c | 11 | ||||
| -rw-r--r-- | sys/dev/usb/uvideo.c | 17 |
14 files changed, 58 insertions, 154 deletions
diff --git a/sys/dev/acpi/acpi_srat.c b/sys/dev/acpi/acpi_srat.c index 9209f9c8579..30019bbd396 100644 --- a/sys/dev/acpi/acpi_srat.c +++ b/sys/dev/acpi/acpi_srat.c @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_srat.c,v 1.5 2017/12/28 08:49:28 maxv Exp $ */ +/* $NetBSD: acpi_srat.c,v 1.6 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_srat.c,v 1.5 2017/12/28 08:49:28 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_srat.c,v 1.6 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/kmem.h> @@ -79,7 +79,7 @@ static TAILQ_HEAD(, memlist) memlisthead; static struct cpulist * cpu_alloc(void) { - return kmem_zalloc(sizeof(struct cpulist), KM_NOSLEEP); + return kmem_zalloc(sizeof(struct cpulist), KM_SLEEP); } static void @@ -91,7 +91,7 @@ cpu_free(struct cpulist *c) static struct memlist * mem_alloc(void) { - return kmem_zalloc(sizeof(struct memlist), KM_NOSLEEP); + return kmem_zalloc(sizeof(struct memlist), KM_SLEEP); } static void @@ -335,19 +335,11 @@ acpisrat_refresh(void) nnodes = MAX(cnodes, mnodes) + 1; node_array = kmem_zalloc(nnodes * sizeof(struct acpisrat_node), - KM_NOSLEEP); - if (node_array == NULL) - return ENOMEM; - + KM_SLEEP); cpu_array = kmem_zalloc(ncpus * sizeof(struct acpisrat_cpu), - KM_NOSLEEP); - if (cpu_array == NULL) - return ENOMEM; - + KM_SLEEP); mem_array = kmem_zalloc(nmems * sizeof(struct acpisrat_mem), - KM_NOSLEEP); - if (mem_array == NULL) - return ENOMEM; + KM_SLEEP); i = 0; CPU_FOREACH(citer) { @@ -367,9 +359,9 @@ acpisrat_refresh(void) node_array[i].nodeid = i; node_array[i].cpu = kmem_zalloc(node_array[i].ncpus * - sizeof(struct acpisrat_cpu *), KM_NOSLEEP); + sizeof(struct acpisrat_cpu *), KM_SLEEP); node_array[i].mem = kmem_zalloc(node_array[i].nmems * - sizeof(struct acpisrat_mem *), KM_NOSLEEP); + sizeof(struct acpisrat_mem *), KM_SLEEP); k = 0; for (j = 0; j < ncpus; j++) { @@ -534,4 +526,3 @@ acpisrat_get_node(uint32_t apicid) return NULL; } - diff --git a/sys/dev/hyperv/hvkbd.c b/sys/dev/hyperv/hvkbd.c index 322695809ad..b0ce5abc082 100644 --- a/sys/dev/hyperv/hvkbd.c +++ b/sys/dev/hyperv/hvkbd.c @@ -1,4 +1,4 @@ -/* $NetBSD: hvkbd.c,v 1.2 2019/07/21 16:08:13 rin Exp $ */ +/* $NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $ */ /*- * Copyright (c) 2017 Microsoft Corp. @@ -36,7 +36,7 @@ #endif /* _KERNEL_OPT */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.2 2019/07/21 16:08:13 rin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvkbd.c,v 1.3 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -209,13 +209,7 @@ hvkbd_attach(device_t parent, device_t self, void *aux) STAILQ_INIT(&sc->sc_ks_queue); hvkbd_alloc_keybuf(sc); - sc->sc_buf = kmem_zalloc(HVKBD_BUFSIZE, cold ? KM_NOSLEEP : KM_SLEEP); - if (sc->sc_buf == NULL) { - aprint_error_dev(self, - "failed to allocate channel data buffer\n"); - return; - } - + sc->sc_buf = kmem_zalloc(HVKBD_BUFSIZE, KM_SLEEP); if (vmbus_channel_setdeferred(sc->sc_chan, device_xname(self))) { aprint_error_dev(self, "failed to create the interrupt thread\n"); @@ -266,18 +260,8 @@ hvkbd_alloc_keybuf(struct hvkbd_softc *sc) int i; for (i = 0; i < HVKBD_KEYBUF_SIZE; i++) { - ksi = kmem_zalloc(sizeof(*ksi), cold ? KM_NOSLEEP : KM_SLEEP); - if (ksi != NULL) { - LIST_INSERT_HEAD(&sc->sc_ks_free, ksi, link); - continue; - } - - while ((ksi = LIST_FIRST(&sc->sc_ks_free)) != NULL) { - LIST_REMOVE(ksi, link); - kmem_free(ksi, sizeof(*ksi)); - } - return ENOMEM; - + ksi = kmem_zalloc(sizeof(*ksi), KM_SLEEP); + LIST_INSERT_HEAD(&sc->sc_ks_free, ksi, link); } return 0; diff --git a/sys/dev/hyperv/hvs.c b/sys/dev/hyperv/hvs.c index 2bce33458ec..6a86452a358 100644 --- a/sys/dev/hyperv/hvs.c +++ b/sys/dev/hyperv/hvs.c @@ -1,4 +1,4 @@ -/* $NetBSD: hvs.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $ */ +/* $NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $ */ /* $OpenBSD: hvs.c,v 1.17 2017/08/10 17:22:48 mikeb Exp $ */ /*- @@ -37,7 +37,7 @@ /* #define HVS_DEBUG_IO */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.1 2019/02/15 08:54:01 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: hvs.c,v 1.2 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1040,7 +1040,6 @@ hvs_empty_done(struct hvs_ccb *ccb) static int hvs_alloc_ccbs(struct hvs_softc *sc) { - const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP; const int dmaflags = cold ? BUS_DMA_NOWAIT : BUS_DMA_WAITOK; int i, error; @@ -1049,11 +1048,7 @@ hvs_alloc_ccbs(struct hvs_softc *sc) sc->sc_nccb = HVS_MAX_CCB; sc->sc_ccbs = kmem_zalloc(sc->sc_nccb * sizeof(struct hvs_ccb), - kmemflags); - if (sc->sc_ccbs == NULL) { - aprint_error_dev(sc->sc_dev, "failed to allocate CCBs\n"); - return -1; - } + KM_SLEEP); for (i = 0; i < sc->sc_nccb; i++) { error = bus_dmamap_create(sc->sc_dmat, MAXPHYS, HVS_MAX_SGE, @@ -1066,13 +1061,7 @@ hvs_alloc_ccbs(struct hvs_softc *sc) sc->sc_ccbs[i].ccb_sgl = kmem_zalloc( sizeof(struct vmbus_gpa_range) * (HVS_MAX_SGE + 1), - kmemflags); - if (sc->sc_ccbs[i].ccb_sgl == NULL) { - aprint_error_dev(sc->sc_dev, - "failed to allocate SGL array\n"); - goto errout; - } - + KM_SLEEP); sc->sc_ccbs[i].ccb_rid = i; hvs_put_ccb(sc, &sc->sc_ccbs[i]); } diff --git a/sys/dev/hyperv/if_hvn.c b/sys/dev/hyperv/if_hvn.c index be7dbe2d9fa..add6aac6b23 100644 --- a/sys/dev/hyperv/if_hvn.c +++ b/sys/dev/hyperv/if_hvn.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_hvn.c,v 1.4 2019/07/09 08:46:58 msaitoh Exp $ */ +/* $NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $ */ /* $OpenBSD: if_hvn.c,v 1.39 2018/03/11 14:31:34 mikeb Exp $ */ /*- @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.4 2019/07/09 08:46:58 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_hvn.c,v 1.5 2019/10/01 18:00:08 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -904,7 +904,6 @@ hvn_nvs_attach(struct hvn_softc *sc) HVN_NVS_PROTO_VERSION_2, HVN_NVS_PROTO_VERSION_1 }; - const int kmemflags = cold ? KM_NOSLEEP : KM_SLEEP; struct hvn_nvs_init cmd; struct hvn_nvs_init_resp *rsp; struct hvn_nvs_ndis_init ncmd; @@ -913,12 +912,7 @@ hvn_nvs_attach(struct hvn_softc *sc) uint64_t tid; int i; - sc->sc_nvsbuf = kmem_zalloc(HVN_NVS_BUFSIZE, kmemflags); - if (sc->sc_nvsbuf == NULL) { - DPRINTF("%s: failed to allocate channel data buffer\n", - device_xname(sc->sc_dev)); - return -1; - } + sc->sc_nvsbuf = kmem_zalloc(HVN_NVS_BUFSIZE, KM_SLEEP); /* We need to be able to fit all RNDIS control and data messages */ ringsize = HVN_RNDIS_CTLREQS * diff --git a/sys/dev/hyperv/vmbusic.c b/sys/dev/hyperv/vmbusic.c index 8743759e5f6..964d7c3c76c 100644 --- a/sys/dev/hyperv/vmbusic.c +++ b/sys/dev/hyperv/vmbusic.c @@ -1,4 +1,4 @@ -/* $NetBSD: vmbusic.c,v 1.1 2019/02/15 08:54:02 nonaka Exp $ */ +/* $NetBSD: vmbusic.c,v 1.2 2019/10/01 18:00:08 chs Exp $ */ /*- * Copyright (c) 2014,2016 Microsoft Corp. * All rights reserved. @@ -27,7 +27,7 @@ #include <sys/cdefs.h> #ifdef __KERNEL_RCSID -__KERNEL_RCSID(0, "$NetBSD: vmbusic.c,v 1.1 2019/02/15 08:54:02 nonaka Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vmbusic.c,v 1.2 2019/10/01 18:00:08 chs Exp $"); #endif #ifdef __FBSDID __FBSDID("$FreeBSD: head/sys/dev/hyperv/utilities/vmbus_ic.c 310317 2016-12-20 07:14:24Z sephe $"); @@ -71,7 +71,7 @@ vmbusic_attach(device_t dv, struct vmbus_attach_args *aa, sc->sc_chan = aa->aa_chan; sc->sc_buflen = VMBUS_IC_BRSIZE; - sc->sc_buf = kmem_alloc(sc->sc_buflen, cold ? KM_NOSLEEP : KM_SLEEP); + sc->sc_buf = kmem_alloc(sc->sc_buflen, KM_SLEEP); /* * These services are not performance critical and do not need diff --git a/sys/dev/i2c/ihidev.c b/sys/dev/i2c/ihidev.c index 0f2b4ad62a5..b513da328d4 100644 --- a/sys/dev/i2c/ihidev.c +++ b/sys/dev/i2c/ihidev.c @@ -1,4 +1,4 @@ -/* $NetBSD: ihidev.c,v 1.8 2019/09/26 08:16:26 bouyer Exp $ */ +/* $NetBSD: ihidev.c,v 1.9 2019/10/01 18:00:08 chs Exp $ */ /* $OpenBSD ihidev.c,v 1.13 2017/04/08 02:57:23 deraadt Exp $ */ /*- @@ -54,7 +54,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.8 2019/09/26 08:16:26 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ihidev.c,v 1.9 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -183,11 +183,7 @@ ihidev_attach(device_t parent, device_t self, void *aux) sc->sc_nrepid++; sc->sc_subdevs = kmem_zalloc(sc->sc_nrepid * sizeof(struct ihidev *), - KM_NOSLEEP); - if (sc->sc_subdevs == NULL) { - aprint_error_dev(self, "failed allocating memory\n"); - return; - } + KM_SLEEP); /* find largest report size and allocate memory for input buffer */ sc->sc_isize = le16toh(sc->hid_desc.wMaxInputLength); @@ -203,7 +199,7 @@ ihidev_attach(device_t parent, device_t self, void *aux) DPRINTF(("%s: repid %d size %d\n", sc->sc_dev.dv_xname, repid, repsz)); } - sc->sc_ibuf = kmem_zalloc(sc->sc_isize, KM_NOSLEEP); + sc->sc_ibuf = kmem_zalloc(sc->sc_isize, KM_SLEEP); #if NACPICA > 0 { char buf[100]; diff --git a/sys/dev/i2c/sdtemp.c b/sys/dev/i2c/sdtemp.c index 1096f4a7c86..e1656f0734e 100644 --- a/sys/dev/i2c/sdtemp.c +++ b/sys/dev/i2c/sdtemp.c @@ -1,4 +1,4 @@ -/* $NetBSD: sdtemp.c,v 1.35 2019/02/28 16:56:35 khorben Exp $ */ +/* $NetBSD: sdtemp.c,v 1.36 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.35 2019/02/28 16:56:35 khorben Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.36 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -342,11 +342,7 @@ sdtemp_attach(device_t parent, device_t self, void *aux) sc->sc_sme->sme_get_limits = sdtemp_get_limits; sc->sc_sme->sme_set_limits = sdtemp_set_limits; - sc->sc_sensor = kmem_zalloc(sizeof(envsys_data_t), KM_NOSLEEP); - if (!sc->sc_sensor) { - aprint_error_dev(self, "unable to allocate sc_sensor\n"); - goto bad2; - } + sc->sc_sensor = kmem_zalloc(sizeof(envsys_data_t), KM_SLEEP); /* Initialize sensor data. */ sc->sc_sensor->units = ENVSYS_STEMP; @@ -400,7 +396,6 @@ sdtemp_attach(device_t parent, device_t self, void *aux) bad: kmem_free(sc->sc_sensor, sizeof(envsys_data_t)); -bad2: sysmon_envsys_destroy(sc->sc_sme); } diff --git a/sys/dev/iscsi/iscsi_main.c b/sys/dev/iscsi/iscsi_main.c index c10a7e49d03..69d8c6f19aa 100644 --- a/sys/dev/iscsi/iscsi_main.c +++ b/sys/dev/iscsi/iscsi_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: iscsi_main.c,v 1.31 2019/08/07 00:38:02 pgoyette Exp $ */ +/* $NetBSD: iscsi_main.c,v 1.32 2019/10/01 18:00:08 chs Exp $ */ /*- * Copyright (c) 2004,2005,2006,2011 The NetBSD Foundation, Inc. @@ -217,12 +217,7 @@ iscsiattach(int n) aprint_error("%s: only one device supported\n", iscsi_cd.cd_name); - cf = kmem_alloc(sizeof(struct cfdata), KM_NOSLEEP); - if (cf == NULL) { - aprint_error("%s: couldn't allocate cfdata\n", - iscsi_cd.cd_name); - return; - } + cf = kmem_alloc(sizeof(struct cfdata), KM_SLEEP); cf->cf_name = iscsi_cd.cd_name; cf->cf_atname = iscsi_cd.cd_name; cf->cf_unit = 0; diff --git a/sys/dev/nand/nandemulator.c b/sys/dev/nand/nandemulator.c index 96f74812fee..145d9988fb0 100644 --- a/sys/dev/nand/nandemulator.c +++ b/sys/dev/nand/nandemulator.c @@ -1,4 +1,4 @@ -/* $NetBSD: nandemulator.c,v 1.8 2019/02/05 08:02:19 mrg Exp $ */ +/* $NetBSD: nandemulator.c,v 1.9 2019/10/01 18:00:08 chs Exp $ */ /*- * Copyright (c) 2011 Department of Software Engineering, @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.8 2019/02/05 08:02:19 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nandemulator.c,v 1.9 2019/10/01 18:00:08 chs Exp $"); /* XXX this code likely needs work */ @@ -152,12 +152,7 @@ nandemulatorattach(int n) return; } for (i = 0; i < n; i++) { - cf = kmem_alloc(sizeof(struct cfdata), KM_NOSLEEP); - if (cf == NULL) { - aprint_error("%s: couldn't allocate cfdata\n", - nandemulator_cd.cd_name); - continue; - } + cf = kmem_alloc(sizeof(struct cfdata), KM_SLEEP); cf->cf_name = nandemulator_cd.cd_name; cf->cf_atname = nandemulator_cd.cd_name; cf->cf_unit = i; diff --git a/sys/dev/pci/arcmsr.c b/sys/dev/pci/arcmsr.c index 66aecb51b18..c664735e794 100644 --- a/sys/dev/pci/arcmsr.c +++ b/sys/dev/pci/arcmsr.c @@ -1,4 +1,4 @@ -/* $NetBSD: arcmsr.c,v 1.39 2018/12/09 11:14:01 jdolecek Exp $ */ +/* $NetBSD: arcmsr.c,v 1.40 2019/10/01 18:00:08 chs Exp $ */ /* $OpenBSD: arc.c,v 1.68 2007/10/27 03:28:27 dlg Exp $ */ /* @@ -21,7 +21,7 @@ #include "bio.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.39 2018/12/09 11:14:01 jdolecek Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arcmsr.c,v 1.40 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/buf.h> @@ -2034,10 +2034,7 @@ arc_dmamem_alloc(struct arc_softc *sc, size_t size) struct arc_dmamem *adm; int nsegs; - adm = kmem_zalloc(sizeof(*adm), KM_NOSLEEP); - if (adm == NULL) - return NULL; - + adm = kmem_zalloc(sizeof(*adm), KM_SLEEP); adm->adm_size = size; if (bus_dmamap_create(sc->sc_dmat, size, 1, size, 0, diff --git a/sys/dev/pci/if_vioif.c b/sys/dev/pci/if_vioif.c index 93b59da975a..b4f61435ee3 100644 --- a/sys/dev/pci/if_vioif.c +++ b/sys/dev/pci/if_vioif.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_vioif.c,v 1.50 2019/09/14 21:09:00 christos Exp $ */ +/* $NetBSD: if_vioif.c,v 1.51 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.50 2019/09/14 21:09:00 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_vioif.c,v 1.51 2019/10/01 18:00:08 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_net_mpsafe.h" @@ -356,7 +356,7 @@ vioif_match(device_t parent, cfdata_t match, void *aux) return 0; } -static int +static void vioif_alloc_queues(struct vioif_softc *sc) { int nvq_pairs = sc->sc_max_nvq_pairs; @@ -366,22 +366,14 @@ vioif_alloc_queues(struct vioif_softc *sc) KASSERT(nvq_pairs <= VIRTIO_NET_CTRL_MQ_VQ_PAIRS_MAX); sc->sc_rxq = kmem_zalloc(sizeof(sc->sc_rxq[0]) * nvq_pairs, - KM_NOSLEEP); - if (sc->sc_rxq == NULL) - return -1; - + KM_SLEEP); sc->sc_txq = kmem_zalloc(sizeof(sc->sc_txq[0]) * nvq_pairs, - KM_NOSLEEP); - if (sc->sc_txq == NULL) - return -1; + KM_SLEEP); if (sc->sc_has_ctrl) nvqs++; - sc->sc_vqs = kmem_zalloc(sizeof(sc->sc_vqs[0]) * nvqs, KM_NOSLEEP); - if (sc->sc_vqs == NULL) - return -1; - + sc->sc_vqs = kmem_zalloc(sizeof(sc->sc_vqs[0]) * nvqs, KM_SLEEP); nvqs = 0; for (i = 0; i < nvq_pairs; i++) { sc->sc_rxq[i].rxq_vq = &sc->sc_vqs[nvqs++]; @@ -390,8 +382,6 @@ vioif_alloc_queues(struct vioif_softc *sc) if (sc->sc_has_ctrl) sc->sc_ctrlq.ctrlq_vq = &sc->sc_vqs[nvqs++]; - - return 0; } static void @@ -766,10 +756,7 @@ vioif_attach(device_t parent, device_t self, void *aux) sc->sc_req_nvq_pairs = MIN(sc->sc_max_nvq_pairs, ncpu); } - r = vioif_alloc_queues(sc); - if (r != 0) - goto err; - + vioif_alloc_queues(sc); virtio_child_attach_set_vqs(vsc, sc->sc_vqs, sc->sc_req_nvq_pairs); #ifdef VIOIF_MPSAFE @@ -823,9 +810,7 @@ vioif_attach(device_t parent, device_t self, void *aux) txq->txq_vq->vq_done_ctx = (void *)txq; txq->txq_link_active = sc->sc_link_active; txq->txq_stopping = false; - txq->txq_intrq = pcq_create(txq->txq_vq->vq_num, KM_NOSLEEP); - if (txq->txq_intrq == NULL) - goto err; + txq->txq_intrq = pcq_create(txq->txq_vq->vq_num, KM_SLEEP); } if (sc->sc_has_ctrl) { diff --git a/sys/dev/pci/pciconf.c b/sys/dev/pci/pciconf.c index 806c359df90..91d43ba7f9c 100644 --- a/sys/dev/pci/pciconf.c +++ b/sys/dev/pci/pciconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: pciconf.c,v 1.41 2019/03/01 09:26:00 msaitoh Exp $ */ +/* $NetBSD: pciconf.c,v 1.42 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright 2001 Wasabi Systems, Inc. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.41 2019/03/01 09:26:00 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pciconf.c,v 1.42 2019/10/01 18:00:08 chs Exp $"); #include "opt_pci.h" @@ -319,10 +319,7 @@ query_bus(pciconf_bus_t *parent, pciconf_dev_t *pd, int dev) pcireg_t io, pmem; pciconf_win_t *pi, *pm; - pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_NOSLEEP); - if (!pb) - panic("Unable to allocate memory for PCI configuration."); - + pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_SLEEP); pb->cacheline_size = parent->cacheline_size; pb->parent_bus = parent; alloc_busno(parent, pb); @@ -1115,7 +1112,7 @@ pci_configure_bus(pci_chipset_tag_t pc, struct extent *ioext, pciconf_bus_t *pb; int rv; - pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_NOSLEEP); + pb = kmem_zalloc(sizeof (pciconf_bus_t), KM_SLEEP); pb->busno = firstbus; pb->next_busno = pb->busno + 1; pb->last_busno = 255; diff --git a/sys/dev/pci/virtio.c b/sys/dev/pci/virtio.c index 185783dd370..ba288f83743 100644 --- a/sys/dev/pci/virtio.c +++ b/sys/dev/pci/virtio.c @@ -1,4 +1,4 @@ -/* $NetBSD: virtio.c,v 1.37 2019/01/14 14:55:37 yamaguchi Exp $ */ +/* $NetBSD: virtio.c,v 1.38 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright (c) 2010 Minoura Makoto. @@ -26,7 +26,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.37 2019/01/14 14:55:37 yamaguchi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.38 2019/10/01 18:00:08 chs Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -494,12 +494,7 @@ virtio_alloc_vq(struct virtio_softc *sc, struct virtqueue *vq, int index, /* free slot management */ vq->vq_entries = kmem_zalloc(sizeof(struct vq_entry)*vq_size, - KM_NOSLEEP); - if (vq->vq_entries == NULL) { - r = ENOMEM; - goto err; - } - + KM_SLEEP); virtio_init_vq(sc, vq, false); aprint_verbose_dev(sc->sc_dev, diff --git a/sys/dev/usb/uvideo.c b/sys/dev/usb/uvideo.c index 7504a339250..521f2524d42 100644 --- a/sys/dev/usb/uvideo.c +++ b/sys/dev/usb/uvideo.c @@ -1,4 +1,4 @@ -/* $NetBSD: uvideo.c,v 1.48 2019/09/15 09:21:36 maxv Exp $ */ +/* $NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $ */ /* * Copyright (c) 2008 Patrick Mahoney @@ -42,7 +42,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.48 2019/09/15 09:21:36 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvideo.c,v 1.49 2019/10/01 18:00:08 chs Exp $"); #ifdef _KERNEL_OPT #include "opt_usb.h" @@ -563,12 +563,6 @@ uvideo_attach(device_t parent, device_t self, void *aux) vs = uvideo_find_stream(sc, ifdesc->bInterfaceNumber); if (vs == NULL) { vs = uvideo_stream_alloc(); - if (vs == NULL) { - DPRINTF(("uvideo_attach: " - "failed to alloc stream\n")); - err = USBD_NOMEM; - goto bad; - } err = uvideo_stream_init(vs, sc, ifdesc, ifaceidx); if (err != USBD_NORMAL_COMPLETION) { @@ -765,7 +759,7 @@ uvideo_stream_guess_format(struct uvideo_stream *vs, static struct uvideo_stream * uvideo_stream_alloc(void) { - return kmem_alloc(sizeof(struct uvideo_stream), KM_NOSLEEP); + return kmem_alloc(sizeof(struct uvideo_stream), KM_SLEEP); } @@ -1161,10 +1155,7 @@ uvideo_stream_init_desc(struct uvideo_stream *vs, desc, bEndpointAddress); } - alt = kmem_alloc(sizeof(*alt), KM_NOSLEEP); - if (alt == NULL) - return USBD_NOMEM; - + alt = kmem_alloc(sizeof(*alt), KM_SLEEP); alt->altno = ifdesc->bAlternateSetting; alt->interval = GET(usb_endpoint_descriptor_t, |
