From 978400d3b04daf8f91ba8bb2dcc382a37ef632f4 Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sun, 6 Jan 2008 16:55:53 +0000 Subject: [PATCH] Remove bogus checks after kmalloc(M_WAITOK) which never returns NULL. Reviewed-by: hasso --- sys/bus/firewire/firewire.c | 5 +- sys/bus/firewire/fwdev.c | 4 +- sys/bus/firewire/fwdma.c | 6 +- sys/bus/firewire/fwmem.c | 4 +- sys/bus/firewire/fwohci.c | 6 +- sys/bus/pci/pci.c | 8 +- sys/dev/disk/ata/atapi-cd.c | 9 +- sys/dev/disk/ata/atapi-fd.c | 6 +- sys/dev/disk/ata/atapi-tape.c | 6 +- sys/dev/disk/isp/isp_pci.c | 13 +- sys/dev/disk/mpt/mpt_pci.c | 6 +- sys/dev/disk/nata/ata-raid.c | 173 +++++------------- sys/dev/disk/wt/wt.c | 4 +- sys/dev/drm/drm_scatter.h | 12 +- sys/dev/misc/gpib/gpib.c | 5 +- sys/dev/misc/labpc/labpc.c | 11 +- sys/dev/misc/puc/puc.c | 6 +- sys/dev/netif/ar/if_ar.c | 4 +- sys/dev/netif/aue/if_aue.c | 4 +- sys/dev/netif/axe/if_axe.c | 4 +- sys/dev/netif/fwe/if_fwe.c | 6 +- sys/dev/netif/ic/if_ic.c | 26 +-- sys/dev/netif/ipw/if_ipw.c | 12 +- sys/dev/netif/kue/if_kue.c | 4 +- sys/dev/netif/my/if_my.c | 7 +- sys/dev/netif/plip/if_plip.c | 6 +- sys/dev/netif/sr/if_sr.c | 4 +- sys/dev/netif/txp/if_txp.c | 4 +- sys/dev/raid/amr/amr.c | 12 +- sys/dev/raid/asr/asr.c | 251 +++++++++++---------------- sys/dev/raid/ciss/ciss.c | 12 +- sys/dev/raid/twa/twa.c | 28 +-- sys/dev/raid/twa/twa_cam.c | 7 +- sys/dev/raid/twe/twe.c | 20 +-- sys/dev/sound/pci/ds1.c | 11 +- sys/dev/sound/pci/emu10k1.c | 9 +- sys/dev/sound/pcm/buffer.c | 15 +- sys/dev/sound/pcm/sndstat.c | 6 +- sys/dev/sound/pcm/sound.c | 11 +- sys/dev/sound/pcm/vchan.c | 10 +- sys/dev/usbmisc/uticom/uticom.c | 8 +- sys/dev/video/ctx/ctx.c | 4 +- sys/kern/inflate.c | 9 +- sys/kern/init_main.c | 4 +- sys/kern/kern_exec.c | 6 +- sys/kern/kern_linker.c | 22 +-- sys/kern/kern_module.c | 4 +- sys/kern/kern_sysctl.c | 5 +- sys/kern/sysv_msg.c | 10 +- sys/kern/sysv_sem.c | 8 +- sys/kern/sysv_shm.c | 6 +- sys/kern/uipc_usrreq.c | 4 +- sys/net/bridge/if_bridge.c | 4 +- sys/net/ef/if_ef.c | 8 +- sys/net/i4b/driver/i4b_ipr.c | 9 +- sys/net/i4b/layer4/i4b_i4bdrv.c | 21 +-- sys/net/ppp/if_ppp.c | 5 +- sys/net/rtsock.c | 4 +- sys/netgraph/eiface/ng_eiface.c | 4 +- sys/netgraph/socket/ng_socket.c | 16 +- sys/netgraph/tty/ng_tty.c | 6 +- sys/netinet/ip_carp.c | 15 +- sys/netinet/ip_output.c | 4 +- sys/netinet/sctp_pcb.c | 5 +- sys/netinet6/ip6_output.c | 8 +- sys/netproto/atm/atm_socket.c | 6 +- sys/netproto/ipsec/keysock.c | 4 +- sys/netproto/ipsec/xform_esp.c | 6 +- sys/netproto/ipx/ipx.c | 4 +- sys/netproto/key/keysock.c | 4 +- sys/netproto/ns/ns.c | 4 +- sys/netproto/smb/smb_rq.c | 6 +- sys/netproto/smb/smb_subr.c | 4 +- sys/opencrypto/cryptodev.c | 4 +- sys/platform/pc32/i386/k6_mem.c | 4 +- sys/platform/pc32/i386/sys_machdep.c | 4 +- sys/vfs/nfs/bootp_subr.c | 7 +- sys/vfs/nwfs/nwfs_vfsops.c | 7 +- sys/vfs/smbfs/smbfs_smb.c | 6 +- sys/vfs/udf/udf_vfsops.c | 4 +- 80 files changed, 251 insertions(+), 779 deletions(-) diff --git a/sys/bus/firewire/firewire.c b/sys/bus/firewire/firewire.c index 5ac76a9746..6dffc25b88 100644 --- a/sys/bus/firewire/firewire.c +++ b/sys/bus/firewire/firewire.c @@ -32,7 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/firewire/firewire.c,v 1.68 2004/01/08 14:58:09 simokawa Exp $ - * $DragonFly: src/sys/bus/firewire/firewire.c,v 1.20 2007/11/14 18:27:52 swildner Exp $ + * $DragonFly: src/sys/bus/firewire/firewire.c,v 1.21 2008/01/06 16:55:49 swildner Exp $ * */ @@ -587,8 +587,6 @@ fw_init_crom(struct firewire_comm *fc) fc->crom_src_buf = (struct crom_src_buf *) kmalloc(sizeof(struct crom_src_buf), M_FW, M_WAITOK | M_ZERO); - if (fc->crom_src_buf == NULL) - return; src = &fc->crom_src_buf->src; bzero(src, sizeof(struct crom_src)); @@ -774,7 +772,6 @@ fw_init(struct firewire_comm *fc) SLIST_INIT(&fc->csrfree); for( i = 0 ; i < FWMAXCSRDIR ; i++){ csrd = kmalloc(sizeof(struct csrdir), M_FW, M_WAITOK); - if(csrd == NULL) break; SLIST_INSERT_HEAD(&fc->csrfree, csrd, link); } diff --git a/sys/bus/firewire/fwdev.c b/sys/bus/firewire/fwdev.c index 2a3b584299..93be76e086 100644 --- a/sys/bus/firewire/fwdev.c +++ b/sys/bus/firewire/fwdev.c @@ -32,7 +32,7 @@ * POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/firewire/fwdev.c,v 1.36 2004/01/22 14:41:17 simokawa Exp $ - * $DragonFly: src/sys/bus/firewire/fwdev.c,v 1.19 2007/05/08 02:31:37 dillon Exp $ + * $DragonFly: src/sys/bus/firewire/fwdev.c,v 1.20 2008/01/06 16:55:49 swildner Exp $ * */ @@ -114,8 +114,6 @@ fwdev_allocbuf(struct firewire_comm *fc, struct fw_xferq *q, q->bulkxfer = (struct fw_bulkxfer *) kmalloc( sizeof(struct fw_bulkxfer) * b->nchunk, M_FW, M_WAITOK); - if (q->bulkxfer == NULL) - return(ENOMEM); b->psize = roundup2(b->psize, sizeof(u_int32_t)); q->buf = fwdma_malloc_multiseg(fc, sizeof(u_int32_t), diff --git a/sys/bus/firewire/fwdma.c b/sys/bus/firewire/fwdma.c index 485d049929..122698a647 100644 --- a/sys/bus/firewire/fwdma.c +++ b/sys/bus/firewire/fwdma.c @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/bus/firewire/fwdma.c,v 1.9 2006/12/22 23:12:16 swildner Exp $ + * $DragonFly: src/sys/bus/firewire/fwdma.c,v 1.10 2008/01/06 16:55:49 swildner Exp $ */ #ifndef __DragonFly__ @@ -170,10 +170,6 @@ fwdma_malloc_multiseg(struct firewire_comm *fc, int alignment, } am = (struct fwdma_alloc_multi *)kmalloc(sizeof(struct fwdma_alloc_multi) + sizeof(struct fwdma_seg)*nseg, M_FW, M_WAITOK); - if (am == NULL) { - kprintf("fwdma_malloc_multiseg: malloc failed\n"); - return(NULL); - } am->ssize = ssize; am->esize = esize; am->nseg = 0; diff --git a/sys/bus/firewire/fwmem.c b/sys/bus/firewire/fwmem.c index a36e7fc5b7..99b1aea9d7 100644 --- a/sys/bus/firewire/fwmem.c +++ b/sys/bus/firewire/fwmem.c @@ -31,7 +31,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/bus/firewire/fwmem.c,v 1.15 2006/12/22 23:12:16 swildner Exp $ + * $DragonFly: src/sys/bus/firewire/fwmem.c,v 1.16 2008/01/06 16:55:49 swildner Exp $ */ #ifndef __DragonFly__ @@ -287,8 +287,6 @@ fwmem_open (struct dev_open_args *ap) } else { fms = (struct fwmem_softc *)kmalloc(sizeof(struct fwmem_softc), M_FWMEM, M_WAITOK); - if (fms == NULL) - return ENOMEM; bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64)); dev->si_drv1 = (void *)fms; dev->si_iosize_max = DFLTPHYS; diff --git a/sys/bus/firewire/fwohci.c b/sys/bus/firewire/fwohci.c index feca33df05..7f15db008f 100644 --- a/sys/bus/firewire/fwohci.c +++ b/sys/bus/firewire/fwohci.c @@ -33,7 +33,7 @@ * * $FreeBSD: src/sys/dev/firewire/fwohci.c,v 1.72 2004/01/22 14:41:17 simokawa Exp $ * $FreeBSD: src/sys/dev/firewire/fwohci.c,v 1.1.2.19 2003/05/01 06:24:37 simokawa Exp $ - * $DragonFly: src/sys/bus/firewire/fwohci.c,v 1.15 2006/12/22 23:12:16 swildner Exp $ + * $DragonFly: src/sys/bus/firewire/fwohci.c,v 1.16 2008/01/06 16:55:49 swildner Exp $ */ #define ATRQ_CH 0 @@ -1231,10 +1231,6 @@ fwohci_db_init(struct fwohci_softc *sc, struct fwohci_dbch *dbch) db_tr = (struct fwohcidb_tr *) kmalloc(sizeof(struct fwohcidb_tr) * dbch->ndb, M_FW, M_WAITOK | M_ZERO); - if(db_tr == NULL){ - kprintf("fwohci_db_init: malloc(1) failed\n"); - return; - } #define DB_SIZE(x) (sizeof(struct fwohcidb) * (x)->ndesc) dbch->am = fwdma_malloc_multiseg(&sc->fc, DB_SIZE(dbch), diff --git a/sys/bus/pci/pci.c b/sys/bus/pci/pci.c index 3ae162ba0d..45e9cce4e1 100644 --- a/sys/bus/pci/pci.c +++ b/sys/bus/pci/pci.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/pci/pci.c,v 1.141.2.15 2002/04/30 17:48:18 tmm Exp $ - * $DragonFly: src/sys/bus/pci/pci.c,v 1.50 2007/11/28 11:35:40 sephe Exp $ + * $DragonFly: src/sys/bus/pci/pci.c,v 1.51 2008/01/06 16:55:49 swildner Exp $ * */ @@ -228,8 +228,6 @@ pci_readppb(device_t pcib, int b, int s, int f) pcih1cfgregs *p; p = kmalloc(sizeof (pcih1cfgregs), M_DEVBUF, M_WAITOK | M_ZERO); - if (p == NULL) - return (NULL); p->secstat = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_SECSTAT_1, 2); p->bridgectl = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_BRIDGECTL_1, 2); @@ -272,8 +270,6 @@ pci_readpcb(device_t pcib, int b, int s, int f) pcih2cfgregs *p; p = kmalloc(sizeof (pcih2cfgregs), M_DEVBUF, M_WAITOK | M_ZERO); - if (p == NULL) - return (NULL); p->secstat = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_SECSTAT_2, 2); p->bridgectl = PCIB_READ_CONFIG(pcib, b, s, f, PCIR_BRIDGECTL_2, 2); @@ -344,8 +340,6 @@ pci_read_device(device_t pcib, int b, int s, int f, size_t size) if (PCIB_READ_CONFIG(pcib, b, s, f, PCIR_DEVVENDOR, 4) != -1) { devlist_entry = kmalloc(size, M_DEVBUF, M_WAITOK | M_ZERO); - if (devlist_entry == NULL) - return (NULL); cfg = &devlist_entry->cfg; diff --git a/sys/dev/disk/ata/atapi-cd.c b/sys/dev/disk/ata/atapi-cd.c index d0db8cd58c..413a79ee75 100644 --- a/sys/dev/disk/ata/atapi-cd.c +++ b/sys/dev/disk/ata/atapi-cd.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-cd.c,v 1.48.2.20 2002/11/25 05:30:31 njl Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.36 2007/06/03 03:44:16 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.37 2008/01/06 16:55:49 swildner Exp $ */ #include "opt_ata.h" @@ -851,10 +851,7 @@ acdioctl(struct dev_ioctl_args *ap) #ifndef CD_BUFFER_BLOCKS #define CD_BUFFER_BLOCKS 13 #endif - if (!(buffer = kmalloc(CD_BUFFER_BLOCKS * 2352, M_ACD, M_WAITOK))){ - error = ENOMEM; - break; - } + buffer = kmalloc(CD_BUFFER_BLOCKS * 2352, M_ACD, M_WAITOK); bzero(ccb, sizeof(ccb)); while (frames > 0) { int8_t blocks; @@ -1616,8 +1613,6 @@ acd_send_cue(struct acd_softc *cdp, struct cdr_cuesheet *cuesheet) return error; buffer = kmalloc(cuesheet->len, M_ACD, M_WAITOK); - if (!buffer) - return ENOMEM; if ((error = copyin(cuesheet->entries, buffer, cuesheet->len))) return error; #ifdef ACD_DEBUG diff --git a/sys/dev/disk/ata/atapi-fd.c b/sys/dev/disk/ata/atapi-fd.c index a43c7ee794..6b10cdfe8c 100644 --- a/sys/dev/disk/ata/atapi-fd.c +++ b/sys/dev/disk/ata/atapi-fd.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-fd.c,v 1.44.2.9 2002/07/31 11:19:26 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-fd.c,v 1.21 2007/05/15 00:01:03 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-fd.c,v 1.22 2008/01/06 16:55:49 swildner Exp $ */ #include @@ -83,10 +83,6 @@ afdattach(struct ata_device *atadev) cdev_t dev; fdp = kmalloc(sizeof(struct afd_softc), M_AFD, M_WAITOK | M_ZERO); - if (!fdp) { - ata_prtdev(atadev, "out of memory\n"); - return 0; - } fdp->device = atadev; fdp->lun = ata_get_lun(&afd_lun_map); diff --git a/sys/dev/disk/ata/atapi-tape.c b/sys/dev/disk/ata/atapi-tape.c index 1b96918a2e..a622182931 100644 --- a/sys/dev/disk/ata/atapi-tape.c +++ b/sys/dev/disk/ata/atapi-tape.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.36.2.12 2002/07/31 11:19:26 sos Exp $ - * $DragonFly: src/sys/dev/disk/ata/atapi-tape.c,v 1.21 2007/05/19 00:52:00 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-tape.c,v 1.22 2008/01/06 16:55:49 swildner Exp $ */ #include "opt_ata.h" @@ -93,10 +93,6 @@ astattach(struct ata_device *atadev) cdev_t dev; stp = kmalloc(sizeof(struct ast_softc), M_AST, M_WAITOK | M_ZERO); - if (!stp) { - ata_prtdev(atadev, "out of memory\n"); - return 0; - } stp->device = atadev; stp->lun = ata_get_lun(&ast_lun_map); diff --git a/sys/dev/disk/isp/isp_pci.c b/sys/dev/disk/isp/isp_pci.c index 610ab6def1..e8674dfbc1 100644 --- a/sys/dev/disk/isp/isp_pci.c +++ b/sys/dev/disk/isp/isp_pci.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/isp/isp_pci.c,v 1.78.2.4 2002/10/11 18:50:53 mjacob Exp $ */ -/* $DragonFly: src/sys/dev/disk/isp/isp_pci.c,v 1.12 2006/12/22 23:26:16 swildner Exp $ */ +/* $DragonFly: src/sys/dev/disk/isp/isp_pci.c,v 1.13 2008/01/06 16:55:49 swildner Exp $ */ /* * PCI specific probe and attach routines for Qlogic ISP SCSI adapters. * FreeBSD Version. @@ -1050,19 +1050,8 @@ isp_pci_mbxdma(struct ispsoftc *isp) len = sizeof (XS_T **) * isp->isp_maxcmds; isp->isp_xflist = (XS_T **) kmalloc(len, M_DEVBUF, M_WAITOK | M_ZERO); - if (isp->isp_xflist == NULL) { - isp_prt(isp, ISP_LOGERR, "cannot alloc xflist array"); - ISP_LOCK(isp); - return (1); - } len = sizeof (bus_dmamap_t) * isp->isp_maxcmds; pcs->dmaps = (bus_dmamap_t *) kmalloc(len, M_DEVBUF, M_WAITOK); - if (pcs->dmaps == NULL) { - isp_prt(isp, ISP_LOGERR, "can't alloc dma map storage"); - kfree(isp->isp_xflist, M_DEVBUF); - ISP_LOCK(isp); - return (1); - } /* * Allocate and map the request, result queues, plus FC scratch area. diff --git a/sys/dev/disk/mpt/mpt_pci.c b/sys/dev/disk/mpt/mpt_pci.c index 2f2727aafa..120663fc00 100644 --- a/sys/dev/disk/mpt/mpt_pci.c +++ b/sys/dev/disk/mpt/mpt_pci.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/mpt/mpt_pci.c,v 1.3.2.3 2002/09/24 21:37:25 mjacob Exp $ */ -/* $DragonFly: src/sys/dev/disk/mpt/mpt_pci.c,v 1.10 2008/01/06 01:29:00 swildner Exp $ */ +/* $DragonFly: src/sys/dev/disk/mpt/mpt_pci.c,v 1.11 2008/01/06 16:55:49 swildner Exp $ */ /* * PCI specific probe and attach routines for LSI '909 FC adapters. * FreeBSD Version. @@ -430,10 +430,6 @@ mpt_dma_mem_alloc(mpt_softc_t *mpt) len = sizeof (request_t *) * MPT_REQ_MEM_SIZE(mpt); mpt->request_pool = (request_t *) kmalloc(len, M_DEVBUF, M_WAITOK); - if (mpt->request_pool == NULL) { - device_printf(dev, "cannot allocate request pool\n"); - return (1); - } bzero(mpt->request_pool, len); /* diff --git a/sys/dev/disk/nata/ata-raid.c b/sys/dev/disk/nata/ata-raid.c index 6af2292ff4..02107f9add 100644 --- a/sys/dev/disk/nata/ata-raid.c +++ b/sys/dev/disk/nata/ata-raid.c @@ -24,7 +24,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ata/ata-raid.c,v 1.120 2006/04/15 10:27:41 maxim Exp $ - * $DragonFly: src/sys/dev/disk/nata/ata-raid.c,v 1.7 2007/06/17 03:54:07 y0netan1 Exp $ + * $DragonFly: src/sys/dev/disk/nata/ata-raid.c,v 1.8 2008/01/06 16:55:49 swildner Exp $ */ #include "opt_ata.h" @@ -986,11 +986,8 @@ ata_raid_create(struct ata_ioc_raid_config *config) if (array >= MAX_ARRAYS) return ENOSPC; - if (!(rdp = (struct ar_softc*)kmalloc(sizeof(struct ar_softc), M_AR, - M_WAITOK | M_ZERO))) { - kprintf("ar%d: no memory for metadata storage\n", array); - return ENOMEM; - } + rdp = (struct ar_softc*)kmalloc(sizeof(struct ar_softc), M_AR, + M_WAITOK | M_ZERO); for (disk = 0; disk < config->total_disks; disk++) { if ((subdisk = devclass_get_device(ata_raid_sub_devclass, @@ -1561,8 +1558,7 @@ ata_raid_wipe_metadata(struct ar_softc *rdp) rdp->lun, ata_raid_format(rdp)); return ENXIO; } - if (!(meta = kmalloc(size, M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = kmalloc(size, M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(rdp->disks[disk].dev, lba, meta, size, ATA_R_WRITE | ATA_R_DIRECT)) { device_printf(rdp->disks[disk].dev, "wipe metadata failed\n"); @@ -1584,9 +1580,8 @@ ata_raid_adaptec_read_meta(device_t dev, struct ar_softc **raidp) struct ar_softc *raid; int array, disk, retval = 0; - if (!(meta = (struct adaptec_raid_conf *) - kmalloc(sizeof(struct adaptec_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct adaptec_raid_conf *) + kmalloc(sizeof(struct adaptec_raid_conf), M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, ADP_LBA(parent), meta, sizeof(struct adaptec_raid_conf), ATA_R_READ)) { @@ -1611,10 +1606,6 @@ ata_raid_adaptec_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto adaptec_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_ADAPTEC_RAID)) @@ -1700,9 +1691,8 @@ ata_raid_hptv2_read_meta(device_t dev, struct ar_softc **raidp) struct ar_softc *raid = NULL; int array, disk_number = 0, retval = 0; - if (!(meta = (struct hptv2_raid_conf *) - kmalloc(sizeof(struct hptv2_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct hptv2_raid_conf *)kmalloc(sizeof(struct hptv2_raid_conf), + M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, HPTV2_LBA(parent), meta, sizeof(struct hptv2_raid_conf), ATA_R_READ)) { @@ -1734,10 +1724,6 @@ ata_raid_hptv2_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto hptv2_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_HPTV2_RAID)) @@ -1852,11 +1838,8 @@ ata_raid_hptv2_write_meta(struct ar_softc *rdp) struct timeval timestamp; int disk, error = 0; - if (!(meta = (struct hptv2_raid_conf *) - kmalloc(sizeof(struct hptv2_raid_conf), M_AR, M_WAITOK | M_ZERO))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct hptv2_raid_conf *)kmalloc(sizeof(struct hptv2_raid_conf), + M_AR, M_WAITOK | M_ZERO); microtime(×tamp); rdp->magic_0 = timestamp.tv_sec + 2; @@ -1947,9 +1930,8 @@ ata_raid_hptv3_read_meta(device_t dev, struct ar_softc **raidp) struct ar_softc *raid = NULL; int array, disk_number, retval = 0; - if (!(meta = (struct hptv3_raid_conf *) - kmalloc(sizeof(struct hptv3_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct hptv3_raid_conf *)kmalloc(sizeof(struct hptv3_raid_conf), + M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, HPTV3_LBA(parent), meta, sizeof(struct hptv3_raid_conf), ATA_R_READ)) { @@ -1981,10 +1963,6 @@ ata_raid_hptv3_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto hptv3_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_HPTV3_RAID)) @@ -2089,9 +2067,7 @@ ata_raid_intel_read_meta(device_t dev, struct ar_softc **raidp) int array, count, disk, volume = 1, retval = 0; char *tmp; - if (!(meta = (struct intel_raid_conf *) - kmalloc(1536, M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct intel_raid_conf *)kmalloc(1536, M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, INTEL_LBA(parent), meta, 1024, ATA_R_READ)) { if (testing || bootverbose) @@ -2132,10 +2108,6 @@ ata_raid_intel_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto intel_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_INTEL_RAID)) @@ -2276,11 +2248,7 @@ ata_raid_intel_write_meta(struct ar_softc *rdp) int count, disk, error = 0; char *tmp; - if (!(meta = (struct intel_raid_conf *) - kmalloc(1536, M_AR, M_WAITOK | M_ZERO))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct intel_raid_conf *)kmalloc(1536, M_AR, M_WAITOK | M_ZERO); rdp->generation++; microtime(×tamp); @@ -2392,9 +2360,8 @@ ata_raid_ite_read_meta(device_t dev, struct ar_softc **raidp) int array, disk_number, count, retval = 0; u_int16_t *ptr; - if (!(meta = (struct ite_raid_conf *) - kmalloc(sizeof(struct ite_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct ite_raid_conf *)kmalloc(sizeof(struct ite_raid_conf), M_AR, + M_WAITOK | M_ZERO); if (ata_raid_rw(parent, ITE_LBA(parent), meta, sizeof(struct ite_raid_conf), ATA_R_READ)) { @@ -2433,10 +2400,6 @@ ata_raid_ite_read_meta(device_t dev, struct ar_softc **raidp) if (!raid) { raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!(raid = raidp[array])) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto ite_out; - } } switch (meta->type) { @@ -2514,9 +2477,8 @@ ata_raid_jmicron_read_meta(device_t dev, struct ar_softc **raidp) u_int64_t disk_size; int count, array, disk, total_disks, retval = 0; - if (!(meta = (struct jmicron_raid_conf *) - kmalloc(sizeof(struct jmicron_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct jmicron_raid_conf *) + kmalloc(sizeof(struct jmicron_raid_conf), M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, JMICRON_LBA(parent), meta, sizeof(struct jmicron_raid_conf), ATA_R_READ)) { @@ -2551,10 +2513,6 @@ jmicron_next: raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto jmicron_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_JMICRON_RAID)) @@ -2650,11 +2608,8 @@ ata_raid_jmicron_write_meta(struct ar_softc *rdp) u_int64_t disk_sectors; int disk, error = 0; - if (!(meta = (struct jmicron_raid_conf *) - kmalloc(sizeof(struct jmicron_raid_conf), M_AR, M_WAITOK | M_ZERO))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct jmicron_raid_conf *) + kmalloc(sizeof(struct jmicron_raid_conf), M_AR, M_WAITOK | M_ZERO); rdp->generation++; switch (rdp->type) { @@ -2737,9 +2692,8 @@ ata_raid_lsiv2_read_meta(device_t dev, struct ar_softc **raidp) struct ar_softc *raid = NULL; int array, retval = 0; - if (!(meta = (struct lsiv2_raid_conf *) - kmalloc(sizeof(struct lsiv2_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct lsiv2_raid_conf *)kmalloc(sizeof(struct lsiv2_raid_conf), + M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, LSIV2_LBA(parent), meta, sizeof(struct lsiv2_raid_conf), ATA_R_READ)) { @@ -2766,10 +2720,6 @@ ata_raid_lsiv2_read_meta(device_t dev, struct ar_softc **raidp) raidp[array + meta->raid_number] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array + meta->raid_number]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto lsiv2_out; - } } raid = raidp[array + meta->raid_number]; if (raid->format && (raid->format != AR_F_LSIV2_RAID)) @@ -2861,9 +2811,8 @@ ata_raid_lsiv3_read_meta(device_t dev, struct ar_softc **raidp) u_int8_t checksum, *ptr; int array, entry, count, disk_number, retval = 0; - if (!(meta = (struct lsiv3_raid_conf *) - kmalloc(sizeof(struct lsiv3_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct lsiv3_raid_conf *)kmalloc(sizeof(struct lsiv3_raid_conf), + M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, LSIV3_LBA(parent), meta, sizeof(struct lsiv3_raid_conf), ATA_R_READ)) { @@ -2897,10 +2846,6 @@ ata_raid_lsiv3_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto lsiv3_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_LSIV3_RAID)) { @@ -2997,9 +2942,8 @@ ata_raid_nvidia_read_meta(device_t dev, struct ar_softc **raidp) u_int32_t checksum, *ptr; int array, count, retval = 0; - if (!(meta = (struct nvidia_raid_conf *) - kmalloc(sizeof(struct nvidia_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct nvidia_raid_conf *)kmalloc(sizeof(struct nvidia_raid_conf), + M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, NVIDIA_LBA(parent), meta, sizeof(struct nvidia_raid_conf), ATA_R_READ)) { @@ -3034,10 +2978,6 @@ ata_raid_nvidia_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto nvidia_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_NVIDIA_RAID)) @@ -3122,9 +3062,8 @@ ata_raid_promise_read_meta(device_t dev, struct ar_softc **raidp, int native) u_int32_t checksum, *ptr; int array, count, disk, disksum = 0, retval = 0; - if (!(meta = (struct promise_raid_conf *) - kmalloc(sizeof(struct promise_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct promise_raid_conf *) + kmalloc(sizeof(struct promise_raid_conf), M_AR, M_WAITOK | M_ZERO); if (ata_raid_rw(parent, PROMISE_LBA(parent), meta, sizeof(struct promise_raid_conf), ATA_R_READ)) { @@ -3177,10 +3116,6 @@ ata_raid_promise_read_meta(device_t dev, struct ar_softc **raidp, int native) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto promise_out; - } } raid = raidp[array]; if (raid->format && @@ -3305,11 +3240,8 @@ ata_raid_promise_write_meta(struct ar_softc *rdp) u_int32_t *ckptr; int count, disk, drive, error = 0; - if (!(meta = (struct promise_raid_conf *) - kmalloc(sizeof(struct promise_raid_conf), M_AR, M_WAITOK))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct promise_raid_conf *) + kmalloc(sizeof(struct promise_raid_conf), M_AR, M_WAITOK); rdp->generation++; microtime(×tamp); @@ -3459,9 +3391,8 @@ ata_raid_sii_read_meta(device_t dev, struct ar_softc **raidp) u_int16_t checksum, *ptr; int array, count, disk, retval = 0; - if (!(meta = (struct sii_raid_conf *) - kmalloc(sizeof(struct sii_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct sii_raid_conf *)kmalloc(sizeof(struct sii_raid_conf), M_AR, + M_WAITOK | M_ZERO); if (ata_raid_rw(parent, SII_LBA(parent), meta, sizeof(struct sii_raid_conf), ATA_R_READ)) { @@ -3504,10 +3435,6 @@ ata_raid_sii_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto sii_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_SII_RAID)) @@ -3607,9 +3534,8 @@ ata_raid_sis_read_meta(device_t dev, struct ar_softc **raidp) struct ar_softc *raid = NULL; int array, disk_number, drive, retval = 0; - if (!(meta = (struct sis_raid_conf *) - kmalloc(sizeof(struct sis_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct sis_raid_conf *)kmalloc(sizeof(struct sis_raid_conf), M_AR, + M_WAITOK | M_ZERO); if (ata_raid_rw(parent, SIS_LBA(parent), meta, sizeof(struct sis_raid_conf), ATA_R_READ)) { @@ -3635,10 +3561,6 @@ ata_raid_sis_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto sis_out; - } } raid = raidp[array]; @@ -3724,11 +3646,8 @@ ata_raid_sis_write_meta(struct ar_softc *rdp) struct timeval timestamp; int disk, error = 0; - if (!(meta = (struct sis_raid_conf *) - kmalloc(sizeof(struct sis_raid_conf), M_AR, M_WAITOK | M_ZERO))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct sis_raid_conf *)kmalloc(sizeof(struct sis_raid_conf), M_AR, + M_WAITOK | M_ZERO); rdp->generation++; microtime(×tamp); @@ -3807,9 +3726,8 @@ ata_raid_via_read_meta(device_t dev, struct ar_softc **raidp) u_int8_t checksum, *ptr; int array, count, disk, retval = 0; - if (!(meta = (struct via_raid_conf *) - kmalloc(sizeof(struct via_raid_conf), M_AR, M_WAITOK | M_ZERO))) - return ENOMEM; + meta = (struct via_raid_conf *)kmalloc(sizeof(struct via_raid_conf), M_AR, + M_WAITOK | M_ZERO); if (ata_raid_rw(parent, VIA_LBA(parent), meta, sizeof(struct via_raid_conf), ATA_R_READ)) { @@ -3843,10 +3761,6 @@ ata_raid_via_read_meta(device_t dev, struct ar_softc **raidp) raidp[array] = (struct ar_softc *)kmalloc(sizeof(struct ar_softc), M_AR, M_WAITOK | M_ZERO); - if (!raidp[array]) { - device_printf(parent, "failed to allocate metadata storage\n"); - goto via_out; - } } raid = raidp[array]; if (raid->format && (raid->format != AR_F_VIA_RAID)) @@ -3942,11 +3856,8 @@ ata_raid_via_write_meta(struct ar_softc *rdp) struct via_raid_conf *meta; int disk, error = 0; - if (!(meta = (struct via_raid_conf *) - kmalloc(sizeof(struct via_raid_conf), M_AR, M_WAITOK | M_ZERO))) { - kprintf("ar%d: failed to allocate metadata storage\n", rdp->lun); - return ENOMEM; - } + meta = (struct via_raid_conf *)kmalloc(sizeof(struct via_raid_conf), M_AR, + M_WAITOK | M_ZERO); rdp->generation++; @@ -4218,10 +4129,6 @@ ata_raid_module_event_handler(module_t mod, int what, void *arg) /* setup table to hold metadata for all ATA PseudoRAID arrays */ ata_raid_arrays = kmalloc(sizeof(struct ar_soft *) * MAX_ARRAYS, M_AR, M_WAITOK | M_ZERO); - if (!ata_raid_arrays) { - kprintf("ataraid: no memory for metadata storage\n"); - return ENOMEM; - } #endif /* attach found PseudoRAID arrays */ for (i = 0; i < MAX_ARRAYS; i++) { diff --git a/sys/dev/disk/wt/wt.c b/sys/dev/disk/wt/wt.c index adb1ebb74f..cb2437ae0d 100644 --- a/sys/dev/disk/wt/wt.c +++ b/sys/dev/disk/wt/wt.c @@ -21,7 +21,7 @@ * * Version 1.3, Thu Nov 11 12:09:13 MSK 1993 * $FreeBSD: src/sys/i386/isa/wt.c,v 1.57.2.1 2000/08/08 19:49:53 peter Exp $ - * $DragonFly: src/sys/dev/disk/wt/wt.c,v 1.19 2006/12/22 23:26:17 swildner Exp $ + * $DragonFly: src/sys/dev/disk/wt/wt.c,v 1.20 2008/01/06 16:55:49 swildner Exp $ * */ @@ -335,8 +335,6 @@ wtopen (struct dev_open_args *ap) t->bsize = (minor (dev) & WT_BSIZE) ? 1024 : 512; t->buf = kmalloc (t->bsize, M_TEMP, M_WAITOK); - if (! t->buf) - return (EAGAIN); if (isa_dma_acquire(t->chan)) return(EBUSY); diff --git a/sys/dev/drm/drm_scatter.h b/sys/dev/drm/drm_scatter.h index fbbbea6047..ad92f5f333 100644 --- a/sys/dev/drm/drm_scatter.h +++ b/sys/dev/drm/drm_scatter.h @@ -27,7 +27,7 @@ * Gareth Hughes * * $FreeBSD: src/sys/dev/drm/drm_scatter.h,v 1.4.2.1 2003/04/26 07:05:28 anholt Exp $ - * $DragonFly: src/sys/dev/drm/Attic/drm_scatter.h,v 1.4 2006/09/05 03:48:10 dillon Exp $ + * $DragonFly: src/sys/dev/drm/Attic/drm_scatter.h,v 1.5 2008/01/06 16:55:49 swildner Exp $ */ #include "dev/drm/drmP.h" @@ -85,16 +85,6 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS ) bzero( (void *)entry->busaddr, pages * sizeof(*entry->busaddr) ); entry->virtual = kmalloc( pages << PAGE_SHIFT, DRM(M_DRM), M_WAITOK ); - if ( !entry->virtual ) { - DRM(free)( entry->busaddr, - entry->pages * sizeof(*entry->busaddr), - DRM_MEM_PAGES ); - DRM(free)( entry, - sizeof(*entry), - DRM_MEM_SGLISTS ); - return ENOMEM; - } - bzero( entry->virtual, pages << PAGE_SHIFT ); entry->handle = (unsigned long)entry->virtual; diff --git a/sys/dev/misc/gpib/gpib.c b/sys/dev/misc/gpib/gpib.c index 366294c3b2..29938979f3 100644 --- a/sys/dev/misc/gpib/gpib.c +++ b/sys/dev/misc/gpib/gpib.c @@ -17,7 +17,7 @@ * all derivative works or modified versions. * * $FreeBSD: src/sys/i386/isa/gpib.c,v 1.29 2000/01/29 16:17:32 peter Exp $ - * $DragonFly: src/sys/dev/misc/gpib/gpib.c,v 1.14 2006/12/22 23:26:17 swildner Exp $ + * $DragonFly: src/sys/dev/misc/gpib/gpib.c,v 1.15 2008/01/06 16:55:50 swildner Exp $ * */ /*Please read the README file for usage information*/ @@ -162,10 +162,7 @@ gpopen(struct dev_open_args *ap) return(EBUSY); } - /* Have memory for buffer? */ sc->sc_inbuf = kmalloc(BUFSIZE, M_DEVBUF, M_WAITOK); - if (sc->sc_inbuf == 0) - return(ENOMEM); if (initgpib()) return(EBUSY); sc->sc_flags |= OPEN; diff --git a/sys/dev/misc/labpc/labpc.c b/sys/dev/misc/labpc/labpc.c index 0c433f7b66..4d3c4a5c5d 100644 --- a/sys/dev/misc/labpc/labpc.c +++ b/sys/dev/misc/labpc/labpc.c @@ -39,7 +39,7 @@ * dufault@hda.com * * $FreeBSD: src/sys/i386/isa/labpc.c,v 1.35 1999/09/25 18:24:08 phk Exp $ - * $DragonFly: src/sys/dev/misc/labpc/labpc.c,v 1.21 2006/12/22 23:26:17 swildner Exp $ + * $DragonFly: src/sys/dev/misc/labpc/labpc.c,v 1.22 2008/01/06 16:55:50 swildner Exp $ * */ @@ -398,14 +398,7 @@ labpcinit(void) labpcs = kmalloc(NLABPC * sizeof(struct ctlr *), M_DEVBUF, M_WAITOK | M_ZERO); - /* - * XXX this is really odd code, adding the device only if - * the allocation fails? it could be broken. - */ - if (labpcs) { - return 1; - } - return 0; + return 1; } static int diff --git a/sys/dev/misc/puc/puc.c b/sys/dev/misc/puc/puc.c index 22e321c77b..fb1f7bd918 100644 --- a/sys/dev/misc/puc/puc.c +++ b/sys/dev/misc/puc/puc.c @@ -1,7 +1,7 @@ /* * $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ * $FreeBSD: src/sys/dev/puc/puc.c,v 1.3.2.5 2003/04/04 08:42:17 sobomax Exp $ - * $DragonFly: src/sys/dev/misc/puc/puc.c,v 1.11 2006/12/22 23:26:18 swildner Exp $ + * $DragonFly: src/sys/dev/misc/puc/puc.c,v 1.12 2008/01/06 16:55:50 swildner Exp $ */ /*- @@ -320,10 +320,6 @@ puc_pci_attach(device_t dev) } else { rle->res = kmalloc(sizeof(struct resource), M_DEVBUF, M_WAITOK | M_ZERO); - if (rle->res == NULL) { - kfree(pdev, M_DEVBUF); - return (ENOMEM); - } rle->res->r_start = rman_get_start(res) + sc->sc_desc->ports[i].offset; diff --git a/sys/dev/netif/ar/if_ar.c b/sys/dev/netif/ar/if_ar.c index 7d21f100a2..a633a83915 100644 --- a/sys/dev/netif/ar/if_ar.c +++ b/sys/dev/netif/ar/if_ar.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ar/if_ar.c,v 1.66 2005/01/06 01:42:28 imp Exp $ - * $DragonFly: src/sys/dev/netif/ar/if_ar.c,v 1.22 2007/06/03 20:51:07 dillon Exp $ + * $DragonFly: src/sys/dev/netif/ar/if_ar.c,v 1.23 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -1087,8 +1087,6 @@ arc_init(struct ar_hardc *hc) MALLOC(sc, struct ar_softc *, hc->numports * sizeof(struct ar_softc), M_DEVBUF, M_WAITOK | M_ZERO); - if (sc == NULL) - return; hc->sc = sc; hc->txc_dtr[0] = AR_TXC_DTR_NOTRESET | diff --git a/sys/dev/netif/aue/if_aue.c b/sys/dev/netif/aue/if_aue.c index bac1641ea6..f1816b8743 100644 --- a/sys/dev/netif/aue/if_aue.c +++ b/sys/dev/netif/aue/if_aue.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/usb/if_aue.c,v 1.78 2003/12/17 14:23:07 sanpei Exp $ - * $DragonFly: src/sys/dev/netif/aue/if_aue.c,v 1.36 2007/11/06 07:37:00 hasso Exp $ + * $DragonFly: src/sys/dev/netif/aue/if_aue.c,v 1.37 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -823,8 +823,6 @@ aue_tx_list_init(struct aue_softc *sc) return (ENOBUFS); } c->aue_buf = kmalloc(AUE_BUFSZ, M_USBDEV, M_WAITOK); - if (c->aue_buf == NULL) - return (ENOBUFS); } return (0); diff --git a/sys/dev/netif/axe/if_axe.c b/sys/dev/netif/axe/if_axe.c index 5ef859aefc..8f81f274ab 100644 --- a/sys/dev/netif/axe/if_axe.c +++ b/sys/dev/netif/axe/if_axe.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/usb/if_axe.c,v 1.10 2003/12/08 07:54:14 obrien Exp $ - * $DragonFly: src/sys/dev/netif/axe/if_axe.c,v 1.26 2007/11/06 07:37:00 hasso Exp $ + * $DragonFly: src/sys/dev/netif/axe/if_axe.c,v 1.27 2008/01/06 16:55:50 swildner Exp $ */ /* * ASIX Electronics AX88172 USB 2.0 ethernet driver. Used in the @@ -569,8 +569,6 @@ axe_tx_list_init(struct axe_softc *sc) return(ENOBUFS); } c->axe_buf = kmalloc(AXE_BUFSZ, M_USBDEV, M_WAITOK); - if (c->axe_buf == NULL) - return(ENOBUFS); } return(0); diff --git a/sys/dev/netif/fwe/if_fwe.c b/sys/dev/netif/fwe/if_fwe.c index 975aa97102..a761869d5c 100644 --- a/sys/dev/netif/fwe/if_fwe.c +++ b/sys/dev/netif/fwe/if_fwe.c @@ -32,7 +32,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/firewire/if_fwe.c,v 1.27 2004/01/08 14:58:09 simokawa Exp $ - * $DragonFly: src/sys/dev/netif/fwe/if_fwe.c,v 1.29 2007/09/09 09:14:38 sephe Exp $ + * $DragonFly: src/sys/dev/netif/fwe/if_fwe.c,v 1.30 2008/01/06 16:55:50 swildner Exp $ */ #include "opt_inet.h" @@ -306,10 +306,6 @@ found: xferq->bulkxfer = (struct fw_bulkxfer *) kmalloc( sizeof(struct fw_bulkxfer) * xferq->bnchunk, M_FWE, M_WAITOK); - if (xferq->bulkxfer == NULL) { - if_printf(ifp, "malloc failed\n"); - return; - } STAILQ_INIT(&xferq->stvalid); STAILQ_INIT(&xferq->stfree); STAILQ_INIT(&xferq->stdma); diff --git a/sys/dev/netif/ic/if_ic.c b/sys/dev/netif/ic/if_ic.c index bb6877c62a..6c76866d0e 100644 --- a/sys/dev/netif/ic/if_ic.c +++ b/sys/dev/netif/ic/if_ic.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/iicbus/if_ic.c,v 1.8 1999/12/29 04:35:39 peter Exp $ - * $DragonFly: src/sys/dev/netif/ic/if_ic.c,v 1.17 2006/12/22 23:26:20 swildner Exp $ + * $DragonFly: src/sys/dev/netif/ic/if_ic.c,v 1.18 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -196,17 +196,9 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) sc->ic_obuf = kmalloc(sc->ic_if.if_mtu + ICHDRLEN, M_DEVBUF, M_WAITOK); - if (!sc->ic_obuf) { - iicbus_release_bus(parent, icdev); - return ENOBUFS; - } sc->ic_ifbuf = kmalloc(sc->ic_if.if_mtu + ICHDRLEN, M_DEVBUF, M_WAITOK); - if (!sc->ic_ifbuf) { - iicbus_release_bus(parent, icdev); - return ENOBUFS; - } iicbus_reset(parent, IIC_FASTEST, 0, NULL); @@ -221,25 +213,9 @@ icioctl(struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) /* allocate input buffer */ sc->ic_ifbuf = kmalloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_WAITOK); - if (!sc->ic_ifbuf) { - - sc->ic_ifbuf = iptr; - sc->ic_obuf = optr; - - return ENOBUFS; - } /* allocate output buffer */ sc->ic_ifbuf = kmalloc(ifr->ifr_mtu+ICHDRLEN, M_DEVBUF, M_WAITOK); - if (!sc->ic_obuf) { - - kfree(sc->ic_ifbuf,M_DEVBUF); - - sc->ic_ifbuf = iptr; - sc->ic_obuf = optr; - - return ENOBUFS; - } if (iptr) kfree(iptr,M_DEVBUF); diff --git a/sys/dev/netif/ipw/if_ipw.c b/sys/dev/netif/ipw/if_ipw.c index 1880449b63..1d618b72f6 100644 --- a/sys/dev/netif/ipw/if_ipw.c +++ b/sys/dev/netif/ipw/if_ipw.c @@ -27,7 +27,7 @@ * * $Id: if_ipw.c,v 1.7.2.1 2005/01/13 20:01:03 damien Exp $ * $FreeBSD: src/sys/dev/ipw/if_ipw.c,v 1.7.2.4 2006/01/29 15:13:01 damien Exp $ - * $DragonFly: src/sys/dev/netif/ipw/Attic/if_ipw.c,v 1.20 2007/02/20 14:24:21 sephe Exp $ + * $DragonFly: src/sys/dev/netif/ipw/Attic/if_ipw.c,v 1.21 2008/01/06 16:55:50 swildner Exp $ */ /*- @@ -1811,16 +1811,8 @@ ipw_cache_firmware(struct ipw_softc *sc, void *data) p += sizeof hdr; fw->main = kmalloc(fw->main_size, M_DEVBUF, M_WAITOK); - if (fw->main == NULL) { - error = ENOMEM; - goto fail1; - } fw->ucode = kmalloc(fw->ucode_size, M_DEVBUF, M_WAITOK); - if (fw->ucode == NULL) { - error = ENOMEM; - goto fail2; - } if ((error = copyin(p, fw->main, fw->main_size)) != 0) goto fail3; @@ -1837,7 +1829,7 @@ ipw_cache_firmware(struct ipw_softc *sc, void *data) return 0; fail3: kfree(fw->ucode, M_DEVBUF); -fail2: kfree(fw->main, M_DEVBUF); + kfree(fw->main, M_DEVBUF); fail1: return error; diff --git a/sys/dev/netif/kue/if_kue.c b/sys/dev/netif/kue/if_kue.c index e556eb343e..671664884b 100644 --- a/sys/dev/netif/kue/if_kue.c +++ b/sys/dev/netif/kue/if_kue.c @@ -30,7 +30,7 @@ * THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/dev/usb/if_kue.c,v 1.17.2.9 2003/04/13 02:39:25 murray Exp $ - * $DragonFly: src/sys/dev/netif/kue/if_kue.c,v 1.28 2007/11/06 07:37:00 hasso Exp $ + * $DragonFly: src/sys/dev/netif/kue/if_kue.c,v 1.29 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -592,8 +592,6 @@ kue_tx_list_init(struct kue_softc *sc) return(ENOBUFS); } c->kue_buf = kmalloc(KUE_BUFSZ, M_USBDEV, M_WAITOK); - if (c->kue_buf == NULL) - return(ENOBUFS); } return(0); diff --git a/sys/dev/netif/my/if_my.c b/sys/dev/netif/my/if_my.c index 893979b03e..a1879aa65b 100644 --- a/sys/dev/netif/my/if_my.c +++ b/sys/dev/netif/my/if_my.c @@ -26,7 +26,7 @@ * Written by: yen_cw@myson.com.tw available at: http://www.myson.com.tw/ * * $FreeBSD: src/sys/dev/my/if_my.c,v 1.2.2.4 2002/04/17 02:05:27 julian Exp $ - * $DragonFly: src/sys/dev/netif/my/if_my.c,v 1.28 2007/03/11 03:46:48 swildner Exp $ + * $DragonFly: src/sys/dev/netif/my/if_my.c,v 1.29 2008/01/06 16:55:50 swildner Exp $ * * Myson fast ethernet PCI NIC driver * @@ -870,11 +870,6 @@ my_attach(device_t dev) sc->my_ldata_ptr = kmalloc(sizeof(struct my_list_data) + 8, M_DEVBUF, M_WAITOK); - if (sc->my_ldata_ptr == NULL) { - kprintf("my%d: no memory for list buffers!\n", unit); - error = ENXIO; - goto fail; - } sc->my_ldata = (struct my_list_data *) sc->my_ldata_ptr; round = (unsigned int)sc->my_ldata_ptr & 0xF; roundptr = sc->my_ldata_ptr; diff --git a/sys/dev/netif/plip/if_plip.c b/sys/dev/netif/plip/if_plip.c index f17b4806fa..90449f9ec8 100644 --- a/sys/dev/netif/plip/if_plip.c +++ b/sys/dev/netif/plip/if_plip.c @@ -25,7 +25,7 @@ * * From Id: lpt.c,v 1.55.2.1 1996/11/12 09:08:38 phk Exp * $FreeBSD: src/sys/dev/ppbus/if_plip.c,v 1.19.2.1 2000/05/24 00:20:57 n_hibma Exp $ - * $DragonFly: src/sys/dev/netif/plip/if_plip.c,v 1.19 2006/12/22 23:26:21 swildner Exp $ + * $DragonFly: src/sys/dev/netif/plip/if_plip.c,v 1.20 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -332,10 +332,6 @@ lpioctl (struct ifnet *ifp, u_long cmd, caddr_t data, struct ucred *cr) sc->sc_ifbuf = kmalloc(sc->sc_if.if_mtu + MLPIPHDRLEN, M_DEVBUF, M_WAITOK); - if (!sc->sc_ifbuf) { - ppb_release_bus(ppbus, dev); - return ENOBUFS; - } /* attach our interrupt handler, later detached when the bus is released */ error = BUS_SETUP_INTR(ppbus, dev, sc->res_irq, 0, diff --git a/sys/dev/netif/sr/if_sr.c b/sys/dev/netif/sr/if_sr.c index b7ec85a421..8860292627 100644 --- a/sys/dev/netif/sr/if_sr.c +++ b/sys/dev/netif/sr/if_sr.c @@ -28,7 +28,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sr/if_sr.c,v 1.48.2.1 2002/06/17 15:10:58 jhay Exp $ - * $DragonFly: src/sys/dev/netif/sr/if_sr.c,v 1.22 2007/06/03 20:51:09 dillon Exp $ + * $DragonFly: src/sys/dev/netif/sr/if_sr.c,v 1.23 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -313,8 +313,6 @@ sr_attach(device_t device) MALLOC(sc, struct sr_softc *, hc->numports * sizeof(struct sr_softc), M_DEVBUF, M_WAITOK | M_ZERO); - if (sc == NULL) - goto errexit; hc->sc = sc; /* diff --git a/sys/dev/netif/txp/if_txp.c b/sys/dev/netif/txp/if_txp.c index f36ad23078..9c02996b50 100644 --- a/sys/dev/netif/txp/if_txp.c +++ b/sys/dev/netif/txp/if_txp.c @@ -1,6 +1,6 @@ /* $OpenBSD: if_txp.c,v 1.48 2001/06/27 06:34:50 kjc Exp $ */ /* $FreeBSD: src/sys/dev/txp/if_txp.c,v 1.4.2.4 2001/12/14 19:50:43 jlemon Exp $ */ -/* $DragonFly: src/sys/dev/netif/txp/if_txp.c,v 1.44 2008/01/05 14:02:37 swildner Exp $ */ +/* $DragonFly: src/sys/dev/netif/txp/if_txp.c,v 1.45 2008/01/06 16:55:50 swildner Exp $ */ /* * Copyright (c) 2001 @@ -952,8 +952,6 @@ txp_alloc_rings(struct txp_softc *sc) continue; sc->sc_rxbufs[i].rb_sd = kmalloc(sizeof(struct txp_swdesc), M_DEVBUF, M_WAITOK); - if (sc->sc_rxbufs[i].rb_sd == NULL) - return(ENOBUFS); sd = sc->sc_rxbufs[i].rb_sd; sd->sd_mbuf = NULL; } diff --git a/sys/dev/raid/amr/amr.c b/sys/dev/raid/amr/amr.c index d2199118ca..2e03fa178c 100644 --- a/sys/dev/raid/amr/amr.c +++ b/sys/dev/raid/amr/amr.c @@ -53,7 +53,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/amr/amr.c,v 1.7.2.13 2003/01/15 13:41:18 emoore Exp $ - * $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.24 2007/05/15 22:44:09 dillon Exp $ + * $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.25 2008/01/06 16:55:50 swildner Exp $ */ /* @@ -430,10 +430,7 @@ amr_ioctl(struct dev_ioctl_args *ap) debug(1, "AMR_IO_COMMAND 0x%x", au->au_cmd[0]); /* handle inbound data buffer */ if (au->au_length != 0) { - if ((dp = kmalloc(au->au_length, M_DEVBUF, M_WAITOK)) == NULL) { - error = ENOMEM; - break; - } + dp = kmalloc(au->au_length, M_DEVBUF, M_WAITOK); if ((error = copyin(au->au_buffer, dp, au->au_length)) != 0) break; debug(2, "copyin %ld bytes from %p -> %p", au->au_length, au->au_buffer, dp); @@ -446,10 +443,7 @@ amr_ioctl(struct dev_ioctl_args *ap) /* handle SCSI passthrough command */ if (au->au_cmd[0] == AMR_CMD_PASS) { - if ((apt = kmalloc(sizeof(*apt), M_DEVBUF, M_WAITOK | M_ZERO)) == NULL) { - error = ENOMEM; - break; - } + apt = kmalloc(sizeof(*apt), M_DEVBUF, M_WAITOK | M_ZERO); /* copy cdb */ apt->ap_cdb_length = au->au_cmd[2]; diff --git a/sys/dev/raid/asr/asr.c b/sys/dev/raid/asr/asr.c index 7626f4925c..cdd86d49af 100644 --- a/sys/dev/raid/asr/asr.c +++ b/sys/dev/raid/asr/asr.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/dev/asr/asr.c,v 1.3.2.2 2001/08/23 05:21:29 scottl Exp $ */ -/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.32 2008/01/05 14:02:38 swildner Exp $ */ +/* $DragonFly: src/sys/dev/raid/asr/asr.c,v 1.33 2008/01/06 16:55:51 swildner Exp $ */ /* * Copyright (c) 1996-2000 Distributed Processing Technology Corporation * Copyright (c) 2000-2001 Adaptec Corporation @@ -766,12 +766,11 @@ asr_alloc_ccb ( { OUT union asr_ccb * new_ccb; - if ((new_ccb = (union asr_ccb *)kmalloc(sizeof(*new_ccb), - M_DEVBUF, M_WAITOK | M_ZERO)) != (union asr_ccb *)NULL) { - new_ccb->ccb_h.pinfo.priority = 1; - new_ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX; - new_ccb->ccb_h.spriv_ptr0 = sc; - } + new_ccb = (union asr_ccb *)kmalloc(sizeof(*new_ccb), M_DEVBUF, + M_WAITOK | M_ZERO); + new_ccb->ccb_h.pinfo.priority = 1; + new_ccb->ccb_h.pinfo.index = CAM_UNQUEUED_INDEX; + new_ccb->ccb_h.spriv_ptr0 = sc; return (new_ccb); } /* asr_alloc_ccb */ @@ -1635,11 +1634,8 @@ ASR_acquireLct ( */ MessageSizeInBytes = sizeof(I2O_EXEC_LCT_NOTIFY_MESSAGE) - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT); - if ((Message_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE)kmalloc ( - MessageSizeInBytes, M_TEMP, M_WAITOK)) - == (PI2O_EXEC_LCT_NOTIFY_MESSAGE)NULL) { - return (ENOMEM); - } + Message_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE)kmalloc ( + MessageSizeInBytes, M_TEMP, M_WAITOK); (void)ASR_fillMessage((char *)Message_Ptr, MessageSizeInBytes); I2O_MESSAGE_FRAME_setVersionOffset(&(Message_Ptr->StdMessageFrame), (I2O_VERSION_11 + @@ -1680,11 +1676,7 @@ ASR_acquireLct ( kfree (Message_Ptr, M_TEMP); return (EINVAL); } - if ((sc->ha_LCT = (PI2O_LCT)kmalloc (len, M_TEMP, M_WAITOK)) - == (PI2O_LCT)NULL) { - kfree (Message_Ptr, M_TEMP); - return (ENOMEM); - } + sc->ha_LCT = (PI2O_LCT)kmalloc (len, M_TEMP, M_WAITOK); /* * since this code is reused in several systems, code efficiency * is greater by using a shift operation rather than a divide by @@ -1748,14 +1740,8 @@ ASR_acquireLct ( { PI2O_EXEC_LCT_NOTIFY_MESSAGE NewMessage_Ptr; - if ((NewMessage_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE) - kmalloc (MessageSizeInBytes, M_TEMP, M_WAITOK)) - == (PI2O_EXEC_LCT_NOTIFY_MESSAGE)NULL) { - kfree (sc->ha_LCT, M_TEMP); - sc->ha_LCT = (PI2O_LCT)NULL; - kfree (Message_Ptr, M_TEMP); - return (ENOMEM); - } + NewMessage_Ptr = (PI2O_EXEC_LCT_NOTIFY_MESSAGE) + kmalloc (MessageSizeInBytes, M_TEMP, M_WAITOK); span = ((caddr_t)sg) - (caddr_t)Message_Ptr; bcopy ((caddr_t)Message_Ptr, (caddr_t)NewMessage_Ptr, span); @@ -2122,21 +2108,15 @@ ASR_setSysTab( PI2O_SGE_SIMPLE_ELEMENT sg; int retVal; - if ((SystemTable = (PI2O_SET_SYSTAB_HEADER)kmalloc ( - sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO)) - == (PI2O_SET_SYSTAB_HEADER)NULL) { - return (ENOMEM); - } + SystemTable = (PI2O_SET_SYSTAB_HEADER)kmalloc ( + sizeof(I2O_SET_SYSTAB_HEADER), M_TEMP, M_WAITOK | M_ZERO); for (ha = Asr_softc; ha; ha = ha->ha_next) { ++SystemTable->NumberEntries; } - if ((Message_Ptr = (PI2O_EXEC_SYS_TAB_SET_MESSAGE)kmalloc ( + Message_Ptr = (PI2O_EXEC_SYS_TAB_SET_MESSAGE)kmalloc ( sizeof(I2O_EXEC_SYS_TAB_SET_MESSAGE) - sizeof(I2O_SG_ELEMENT) + ((3+SystemTable->NumberEntries) * sizeof(I2O_SGE_SIMPLE_ELEMENT)), - M_TEMP, M_WAITOK)) == (PI2O_EXEC_SYS_TAB_SET_MESSAGE)NULL) { - kfree (SystemTable, M_TEMP); - return (ENOMEM); - } + M_TEMP, M_WAITOK); (void)ASR_fillMessage((char *)Message_Ptr, sizeof(I2O_EXEC_SYS_TAB_SET_MESSAGE) - sizeof(I2O_SG_ELEMENT) + ((3+SystemTable->NumberEntries) * sizeof(I2O_SGE_SIMPLE_ELEMENT))); @@ -2659,84 +2639,82 @@ asr_attach (ATTACH_ARGS) kprintf ("asr%d:", unit); - if ((iq = (struct scsi_inquiry_data *)kmalloc ( - sizeof(struct scsi_inquiry_data), M_TEMP, M_WAITOK | M_ZERO)) - != (struct scsi_inquiry_data *)NULL) { - defAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE,Message); - PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE Message_Ptr; - int posted = 0; + iq = (struct scsi_inquiry_data *)kmalloc ( + sizeof(struct scsi_inquiry_data), M_TEMP, M_WAITOK | M_ZERO); + defAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE,Message); + PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE Message_Ptr; + int posted = 0; - bzero (Message_Ptr - = getAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE, Message), - sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) - - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT)); + bzero (Message_Ptr + = getAlignLong(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE, Message), + sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) + - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT)); - I2O_MESSAGE_FRAME_setVersionOffset( - (PI2O_MESSAGE_FRAME)Message_Ptr, - I2O_VERSION_11 - | (((sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) - - sizeof(I2O_SG_ELEMENT)) - / sizeof(U32)) << 4)); - I2O_MESSAGE_FRAME_setMessageSize( - (PI2O_MESSAGE_FRAME)Message_Ptr, - (sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) - - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT)) - / sizeof(U32)); - I2O_MESSAGE_FRAME_setInitiatorAddress ( - (PI2O_MESSAGE_FRAME)Message_Ptr, 1); - I2O_MESSAGE_FRAME_setFunction( - (PI2O_MESSAGE_FRAME)Message_Ptr, I2O_PRIVATE_MESSAGE); - I2O_PRIVATE_MESSAGE_FRAME_setXFunctionCode ( - (PI2O_PRIVATE_MESSAGE_FRAME)Message_Ptr, - I2O_SCSI_SCB_EXEC); - PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setSCBFlags (Message_Ptr, - I2O_SCB_FLAG_ENABLE_DISCONNECT - | I2O_SCB_FLAG_SIMPLE_QUEUE_TAG - | I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER); - PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setInterpret(Message_Ptr, 1); - I2O_PRIVATE_MESSAGE_FRAME_setOrganizationID( - (PI2O_PRIVATE_MESSAGE_FRAME)Message_Ptr, - DPT_ORGANIZATION_ID); - PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setCDBLength(Message_Ptr, 6); - Message_Ptr->CDB[0] = INQUIRY; - Message_Ptr->CDB[4] = (unsigned char)sizeof(struct scsi_inquiry_data); - if (Message_Ptr->CDB[4] == 0) { - Message_Ptr->CDB[4] = 255; - } + I2O_MESSAGE_FRAME_setVersionOffset( + (PI2O_MESSAGE_FRAME)Message_Ptr, + I2O_VERSION_11 + | (((sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) + - sizeof(I2O_SG_ELEMENT)) + / sizeof(U32)) << 4)); + I2O_MESSAGE_FRAME_setMessageSize( + (PI2O_MESSAGE_FRAME)Message_Ptr, + (sizeof(PRIVATE_SCSI_SCB_EXECUTE_MESSAGE) + - sizeof(I2O_SG_ELEMENT) + sizeof(I2O_SGE_SIMPLE_ELEMENT)) + / sizeof(U32)); + I2O_MESSAGE_FRAME_setInitiatorAddress ( + (PI2O_MESSAGE_FRAME)Message_Ptr, 1); + I2O_MESSAGE_FRAME_setFunction( + (PI2O_MESSAGE_FRAME)Message_Ptr, I2O_PRIVATE_MESSAGE); + I2O_PRIVATE_MESSAGE_FRAME_setXFunctionCode ( + (PI2O_PRIVATE_MESSAGE_FRAME)Message_Ptr, + I2O_SCSI_SCB_EXEC); + PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setSCBFlags (Message_Ptr, + I2O_SCB_FLAG_ENABLE_DISCONNECT + | I2O_SCB_FLAG_SIMPLE_QUEUE_TAG + | I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER); + PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setInterpret(Message_Ptr, 1); + I2O_PRIVATE_MESSAGE_FRAME_setOrganizationID( + (PI2O_PRIVATE_MESSAGE_FRAME)Message_Ptr, + DPT_ORGANIZATION_ID); + PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setCDBLength(Message_Ptr, 6); + Message_Ptr->CDB[0] = INQUIRY; + Message_Ptr->CDB[4] = (unsigned char)sizeof(struct scsi_inquiry_data); + if (Message_Ptr->CDB[4] == 0) { + Message_Ptr->CDB[4] = 255; + } - PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setSCBFlags (Message_Ptr, - (I2O_SCB_FLAG_XFER_FROM_DEVICE - | I2O_SCB_FLAG_ENABLE_DISCONNECT - | I2O_SCB_FLAG_SIMPLE_QUEUE_TAG - | I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER)); + PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setSCBFlags (Message_Ptr, + (I2O_SCB_FLAG_XFER_FROM_DEVICE + | I2O_SCB_FLAG_ENABLE_DISCONNECT + | I2O_SCB_FLAG_SIMPLE_QUEUE_TAG + | I2O_SCB_FLAG_SENSE_DATA_IN_BUFFER)); - PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setByteCount( - (PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)Message_Ptr, - sizeof(struct scsi_inquiry_data)); - SG(&(Message_Ptr->SGL), 0, - I2O_SGL_FLAGS_LAST_ELEMENT | I2O_SGL_FLAGS_END_OF_BUFFER, - iq, sizeof(struct scsi_inquiry_data)); - (void)ASR_queue_c(sc, (PI2O_MESSAGE_FRAME)Message_Ptr); + PRIVATE_SCSI_SCB_EXECUTE_MESSAGE_setByteCount( + (PPRIVATE_SCSI_SCB_EXECUTE_MESSAGE)Message_Ptr, + sizeof(struct scsi_inquiry_data)); + SG(&(Message_Ptr->SGL), 0, + I2O_SGL_FLAGS_LAST_ELEMENT | I2O_SGL_FLAGS_END_OF_BUFFER, + iq, sizeof(struct scsi_inquiry_data)); + (void)ASR_queue_c(sc, (PI2O_MESSAGE_FRAME)Message_Ptr); - if (iq->vendor[0] && (iq->vendor[0] != ' ')) { - kprintf (" "); - ASR_prstring (iq->vendor, 8); - ++posted; - } - if (iq->product[0] && (iq->product[0] != ' ')) { - kprintf (" "); - ASR_prstring (iq->product, 16); - ++posted; - } - if (iq->revision[0] && (iq->revision[0] != ' ')) { - kprintf (" FW Rev. "); - ASR_prstring (iq->revision, 4); - ++posted; - } - kfree ((caddr_t)iq, M_TEMP); - if (posted) { - kprintf (","); - } + if (iq->vendor[0] && (iq->vendor[0] != ' ')) { + kprintf (" "); + ASR_prstring (iq->vendor, 8); + ++posted; + } + if (iq->product[0] && (iq->product[0] != ' ')) { + kprintf (" "); + ASR_prstring (iq->product, 16); + ++posted; + } + if (iq->revision[0] && (iq->revision[0] != ' ')) { + kprintf (" FW Rev. "); + ASR_prstring (iq->revision, 4); + ++posted; + } + kfree ((caddr_t)iq, M_TEMP); + if (posted) { + kprintf (","); } kprintf (" %d channel, %d CCBs, Protocol I2O\n", sc->ha_MaxBus + 1, (sc->ha_QueueSize > MAX_INBOUND) ? MAX_INBOUND : sc->ha_QueueSize); @@ -3342,13 +3320,8 @@ ASR_queue_i( return (EIO); } /* Copy in the message into a local allocation */ - if ((Message_Ptr = (PI2O_MESSAGE_FRAME)kmalloc ( - sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) - == (PI2O_MESSAGE_FRAME)NULL) { - debug_usr_cmd_printf ( - "Failed to acquire I2O_MESSAGE_FRAME memory\n"); - return (ENOMEM); - } + Message_Ptr = (PI2O_MESSAGE_FRAME)kmalloc ( + sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK); if ((error = copyin ((caddr_t)Packet, (caddr_t)Message_Ptr, sizeof(I2O_MESSAGE_FRAME))) != 0) { kfree (Message_Ptr, M_TEMP); @@ -3409,12 +3382,8 @@ ASR_queue_i( return (EINVAL); } - if ((Message_Ptr = (PI2O_MESSAGE_FRAME)kmalloc (MessageSizeInBytes, - M_TEMP, M_WAITOK)) == (PI2O_MESSAGE_FRAME)NULL) { - debug_usr_cmd_printf ("Failed to acquire frame[%d] memory\n", - MessageSizeInBytes); - return (ENOMEM); - } + Message_Ptr = (PI2O_MESSAGE_FRAME)kmalloc (MessageSizeInBytes, + M_TEMP, M_WAITOK); if ((error = copyin ((caddr_t)Packet, (caddr_t)Message_Ptr, MessageSizeInBytes)) != 0) { kfree (Message_Ptr, M_TEMP); @@ -3425,14 +3394,8 @@ ASR_queue_i( /* Check the size of the reply frame, and start constructing */ - if ((Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)kmalloc ( - sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK)) - == (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { - kfree (Message_Ptr, M_TEMP); - debug_usr_cmd_printf ( - "Failed to acquire I2O_MESSAGE_FRAME memory\n"); - return (ENOMEM); - } + Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)kmalloc ( + sizeof(I2O_MESSAGE_FRAME), M_TEMP, M_WAITOK); if ((error = copyin ((caddr_t)Reply, (caddr_t)Reply_Ptr, sizeof(I2O_MESSAGE_FRAME))) != 0) { kfree (Reply_Ptr, M_TEMP); @@ -3453,16 +3416,11 @@ ASR_queue_i( return (EINVAL); } - if ((Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)kmalloc ( + Reply_Ptr = (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)kmalloc ( ((ReplySizeInBytes > sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)) ? ReplySizeInBytes : sizeof(I2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)), - M_TEMP, M_WAITOK)) == (PI2O_SCSI_ERROR_REPLY_MESSAGE_FRAME)NULL) { - kfree (Message_Ptr, M_TEMP); - debug_usr_cmd_printf ("Failed to acquire frame[%d] memory\n", - ReplySizeInBytes); - return (ENOMEM); - } + M_TEMP, M_WAITOK); (void)ASR_fillMessage ((char *)Reply_Ptr, ReplySizeInBytes); Reply_Ptr->StdReplyFrame.StdMessageFrame.InitiatorContext = Message_Ptr->InitiatorContext; @@ -3524,15 +3482,9 @@ ASR_queue_i( Message_Ptr) & 0xF0) >> 2)), I2O_SGE_SIMPLE_ELEMENT_getPhysicalAddress(sg), len); - if ((elm = (struct ioctlSgList_S *)kmalloc ( + elm = (struct ioctlSgList_S *)kmalloc ( sizeof(*elm) - sizeof(elm->KernelSpace) + len, - M_TEMP, M_WAITOK)) - == (struct ioctlSgList_S *)NULL) { - debug_usr_cmd_printf ( - "Failed to allocate SG[%d]\n", len); - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); SLIST_INSERT_HEAD(&sgList, elm, link); elm->FlagsCount = sg->FlagsCount; elm->UserSpace = (caddr_t) @@ -3612,17 +3564,10 @@ ASR_queue_i( { PI2O_MESSAGE_FRAME NewMessage_Ptr; - if ((NewMessage_Ptr + NewMessage_Ptr = (PI2O_MESSAGE_FRAME) kmalloc (MessageSizeInBytes, - M_TEMP, M_WAITOK)) - == (PI2O_MESSAGE_FRAME)NULL) { - debug_usr_cmd_printf ( - "Failed to acquire frame[%d] memory\n", - MessageSizeInBytes); - error = ENOMEM; - break; - } + M_TEMP, M_WAITOK); span = ((caddr_t)sg) - (caddr_t)Message_Ptr; bcopy ((caddr_t)Message_Ptr, diff --git a/sys/dev/raid/ciss/ciss.c b/sys/dev/raid/ciss/ciss.c index 020dd11851..18a7ce3543 100644 --- a/sys/dev/raid/ciss/ciss.c +++ b/sys/dev/raid/ciss/ciss.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/ciss/ciss.c,v 1.2.2.6 2003/02/18 22:27:41 ps Exp $ - * $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.25 2007/12/23 07:00:57 pavalos Exp $ + * $DragonFly: src/sys/dev/raid/ciss/ciss.c,v 1.26 2008/01/06 16:55:51 swildner Exp $ */ /* @@ -1925,10 +1925,7 @@ ciss_user_command(struct ciss_softc *sc, IOCTL_Command_struct *ioc) */ cr->cr_length = ioc->buf_size; if (ioc->buf_size > 0) { - if ((cr->cr_data = kmalloc(ioc->buf_size, CISS_MALLOC_CLASS, M_WAITOK)) == NULL) { - error = ENOMEM; - goto out; - } + cr->cr_data = kmalloc(ioc->buf_size, CISS_MALLOC_CLASS, M_WAITOK); if ((error = copyin(ioc->buf, cr->cr_data, ioc->buf_size))) { debug(0, "copyin: bad data buffer %p/%d", ioc->buf, ioc->buf_size); goto out; @@ -2106,10 +2103,7 @@ ciss_cam_rescan_target(struct ciss_softc *sc, int target) debug_called(1); - if ((ccb = kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO)) == NULL) { - ciss_printf(sc, "rescan failed (can't allocate CCB)\n"); - return; - } + ccb = kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); if (xpt_create_path(&sc->ciss_cam_path, xpt_periph, cam_sim_path(sc->ciss_cam_sim), target, 0) != CAM_REQ_CMP) { diff --git a/sys/dev/raid/twa/twa.c b/sys/dev/raid/twa/twa.c index e10bd4b4b0..0737fc5e57 100644 --- a/sys/dev/raid/twa/twa.c +++ b/sys/dev/raid/twa/twa.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD$ - * $DragonFly: src/sys/dev/raid/twa/twa.c,v 1.7 2008/01/05 14:02:38 swildner Exp $ + * $DragonFly: src/sys/dev/raid/twa/twa.c,v 1.8 2008/01/06 16:55:51 swildner Exp $ */ /* @@ -110,17 +110,8 @@ twa_setup(struct twa_softc *sc) } /* Allocate memory for the AEN queue. */ - if ((aen_queue = kmalloc(sizeof(struct twa_event_packet) * TWA_Q_LENGTH, - M_DEVBUF, M_WAITOK | M_ZERO)) == NULL) { - /* - * This should not cause us to return error. We will only be - * unable to support AEN's. But then, we will have to check - * time and again to see if we can support AEN's, if we - * continue. So, we will just return error. - */ - twa_printf(sc, "Could not allocate memory for AEN queue.\n"); - return(ENOMEM); /* any unfreed memory will be freed by twa_free */ - } + aen_queue = kmalloc(sizeof(struct twa_event_packet) * TWA_Q_LENGTH, + M_DEVBUF, M_WAITOK | M_ZERO); /* Initialize the aen queue. */ for (i = 0; i < TWA_Q_LENGTH; i++) sc->twa_aen_queue[i] = &(aen_queue[i]); @@ -172,11 +163,7 @@ twa_flash_firmware(struct twa_softc *sc) tr->tr_cmd_pkt_type |= TWA_CMD_PKT_TYPE_INTERNAL; /* Allocate sufficient memory to hold a chunk of the firmware image. */ fw_img_chunk_size = ((twa_fw_img_size/NUM_FW_IMAGE_CHUNKS) + 511) & ~511; - if ((tr->tr_data = kmalloc(fw_img_chunk_size, M_DEVBUF, M_WAITOK)) == NULL) { - twa_printf (sc, "Could not allocate memory for firmware image.\n"); - error = ENOMEM; - goto out; - } + tr->tr_data = kmalloc(fw_img_chunk_size, M_DEVBUF, M_WAITOK); remaining_img_size = twa_fw_img_size; cmd = &(tr->tr_command->command.cmd_pkt_7k.download_fw); @@ -582,11 +569,8 @@ twa_ioctl(struct twa_softc *sc, int cmd, void *buf) */ data_buf_size_adjusted = (user_buf->twa_drvr_pkt.buffer_length + 511) & ~511; if ((tr->tr_length = data_buf_size_adjusted)) { - if ((tr->tr_data = kmalloc(data_buf_size_adjusted, M_DEVBUF, M_WAITOK)) == NULL) { - twa_printf(sc, "Could not alloc mem for fw_passthru data_buf.\n"); - error = ENOMEM; - goto fw_passthru_done; - } + tr->tr_data = kmalloc(data_buf_size_adjusted, M_DEVBUF, + M_WAITOK); /* Copy the payload. */ if ((error = copyin((void *) (user_buf->pdata), (void *) (tr->tr_data), diff --git a/sys/dev/raid/twa/twa_cam.c b/sys/dev/raid/twa/twa_cam.c index befdf12ce7..cd07eb740f 100644 --- a/sys/dev/raid/twa/twa_cam.c +++ b/sys/dev/raid/twa/twa_cam.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD$ - * $DragonFly: src/sys/dev/raid/twa/twa_cam.c,v 1.5 2008/01/05 14:02:38 swildner Exp $ + * $DragonFly: src/sys/dev/raid/twa/twa_cam.c,v 1.6 2008/01/06 16:55:51 swildner Exp $ */ /* @@ -507,10 +507,9 @@ void twa_request_bus_scan(struct twa_softc *sc) { struct cam_path *path; - union ccb *ccb; + union ccb *ccb = NULL; - if ((ccb = kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK|M_ZERO)) == NULL) - return; + kmalloc(sizeof(union ccb), M_TEMP, M_WAITOK | M_ZERO); if (xpt_create_path(&path, xpt_periph, cam_sim_path(sc->twa_sim), CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD) != CAM_REQ_CMP) return; diff --git a/sys/dev/raid/twe/twe.c b/sys/dev/raid/twe/twe.c index 29194d2e0d..edd21bcf94 100644 --- a/sys/dev/raid/twe/twe.c +++ b/sys/dev/raid/twe/twe.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/twe/twe.c,v 1.1.2.10 2004/06/11 18:57:31 vkashyap Exp $ - * $DragonFly: src/sys/dev/raid/twe/twe.c,v 1.18 2007/05/15 22:44:11 dillon Exp $ + * $DragonFly: src/sys/dev/raid/twe/twe.c,v 1.19 2008/01/06 16:55:51 swildner Exp $ */ /* @@ -525,10 +525,7 @@ twe_ioctl(struct twe_softc *sc, int cmd, void *addr) */ tr->tr_length = (tu->tu_size + 511) & ~511; if (tr->tr_length > 0) { - if ((tr->tr_data = kmalloc(tr->tr_length, M_DEVBUF, M_WAITOK)) == NULL) { - error = ENOMEM; - goto cmd_done; - } + tr->tr_data = kmalloc(tr->tr_length, M_DEVBUF, M_WAITOK); if ((error = copyin(tu->tu_data, tr->tr_data, tu->tu_size)) != 0) goto cmd_done; tr->tr_flags |= TWE_CMD_DATAIN | TWE_CMD_DATAOUT; @@ -607,14 +604,11 @@ twe_ioctl(struct twe_softc *sc, int cmd, void *addr) break; case TWEIO_SET_PARAM: - if ((data = kmalloc(tp->tp_size, M_DEVBUF, M_WAITOK)) == NULL) { - error = ENOMEM; - } else { - error = copyin(tp->tp_data, data, tp->tp_size); - if (error == 0) - error = twe_set_param(sc, tp->tp_table_id, tp->tp_param_id, tp->tp_size, data); - kfree(data, M_DEVBUF); - } + data = kmalloc(tp->tp_size, M_DEVBUF, M_WAITOK); + error = copyin(tp->tp_data, data, tp->tp_size); + if (error == 0) + error = twe_set_param(sc, tp->tp_table_id, tp->tp_param_id, tp->tp_size, data); + kfree(data, M_DEVBUF); break; case TWEIO_RESET: diff --git a/sys/dev/sound/pci/ds1.c b/sys/dev/sound/pci/ds1.c index 042471153e..08d8a6f455 100644 --- a/sys/dev/sound/pci/ds1.c +++ b/sys/dev/sound/pci/ds1.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/ds1.c,v 1.43.2.1 2006/01/18 01:05:34 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.9 2007/06/16 20:07:19 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.10 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -36,7 +36,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.9 2007/06/16 20:07:19 dillon Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/ds1.c,v 1.10 2008/01/06 16:55:51 swildner Exp $"); /* -------------------------------------------------------------------- */ @@ -940,14 +940,11 @@ ds_pci_attach(device_t dev) { u_int32_t data; u_int32_t subdev, i; - struct sc_info *sc; + struct sc_info *sc = NULL; struct ac97_info *codec = NULL; char status[SND_STATUSLEN]; - if ((sc = kmalloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO)) == NULL) { - device_printf(dev, "cannot allocate softc\n"); - return ENXIO; - } + kmalloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc"); sc->dev = dev; diff --git a/sys/dev/sound/pci/emu10k1.c b/sys/dev/sound/pci/emu10k1.c index 8b3137612b..b90af92d30 100644 --- a/sys/dev/sound/pci/emu10k1.c +++ b/sys/dev/sound/pci/emu10k1.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pci/emu10k1.c,v 1.55.2.1 2005/12/30 19:55:53 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.13 2007/06/16 20:07:19 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.14 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -38,7 +38,7 @@ #include #include -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.13 2007/06/16 20:07:19 dillon Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pci/emu10k1.c,v 1.14 2008/01/06 16:55:51 swildner Exp $"); /* -------------------------------------------------------------------- */ @@ -1915,10 +1915,7 @@ emu_pci_attach(device_t dev) int i, gotmic; char status[SND_STATUSLEN]; - if ((sc = kmalloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO)) == NULL) { - device_printf(dev, "cannot allocate softc\n"); - return ENXIO; - } + sc = kmalloc(sizeof(*sc), M_DEVBUF, M_WAITOK | M_ZERO); sc->lock = snd_mtxcreate(device_get_nameunit(dev), "sound softc"); sc->dev = dev; diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c index 0bf4522a96..1581806c97 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -24,14 +24,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/buffer.c,v 1.25.2.3 2007/04/26 08:21:43 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.10 2008/01/05 13:34:22 corecode Exp $ + * $DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.11 2008/01/06 16:55:51 swildner Exp $ */ #include #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.10 2008/01/05 13:34:22 corecode Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.11 2008/01/06 16:55:51 swildner Exp $"); /* * sndbuf_seltask is a taskqueue callback routine, called from @@ -211,17 +211,7 @@ sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz) chn_unlock(b->channel); buf = kmalloc(bufsize, M_DEVBUF, M_WAITOK); - if (buf == NULL) { - ret = ENOMEM; - goto out; - } - tmpbuf = kmalloc(bufsize, M_DEVBUF, M_WAITOK); - if (tmpbuf == NULL) { - kfree(buf, M_DEVBUF); - ret = ENOMEM; - goto out; - } chn_lock(b->channel); b->blkcnt = blkcnt; @@ -242,7 +232,6 @@ sndbuf_remalloc(struct snd_dbuf *b, unsigned int blkcnt, unsigned int blksz) kfree(f2, M_DEVBUF); ret = 0; -out: chn_lock(b->channel); return ret; } diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index 08471e4527..1e349487fc 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sndstat.c,v 1.20.2.2 2005/12/30 19:55:54 netchild Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sndstat.c,v 1.12 2007/05/08 02:31:42 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pcm/sndstat.c,v 1.13 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -33,7 +33,7 @@ #include #endif -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sndstat.c,v 1.12 2007/05/08 02:31:42 dillon Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sndstat.c,v 1.13 2008/01/06 16:55:51 swildner Exp $"); #define SS_TYPE_MODULE 0 #define SS_TYPE_FIRST 1 @@ -228,8 +228,6 @@ sndstat_register(device_t dev, char *str, sndstat_handler handler) } ent = kmalloc(sizeof *ent, M_DEVBUF, M_ZERO | M_WAITOK); - if (!ent) - return ENOSPC; ent->dev = dev; ent->str = str; diff --git a/sys/dev/sound/pcm/sound.c b/sys/dev/sound/pcm/sound.c index 1c332ca1f2..bc3c263d28 100644 --- a/sys/dev/sound/pcm/sound.c +++ b/sys/dev/sound/pcm/sound.c @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sound.c,v 1.93.2.5 2007/06/04 09:06:05 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.11 2007/06/16 20:07:22 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.12 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -35,7 +35,7 @@ #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.11 2007/06/16 20:07:22 dillon Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/sound.c,v 1.12 2008/01/06 16:55:51 swildner Exp $"); devclass_t pcm_devclass; @@ -76,8 +76,6 @@ snd_mtxcreate(const char *desc, const char *type) struct lock *m; m = kmalloc(sizeof(*m), M_DEVBUF, M_WAITOK | M_ZERO); - if (m == NULL) - return NULL; lockinit(m, __DECONST(char *, type), 0, LK_CANRECURSE); return m; #else @@ -461,8 +459,6 @@ pcm_chn_create(struct snddev_info *d, struct pcm_channel *parent, kobj_class_t c } ch = kmalloc(sizeof(*ch), M_DEVBUF, M_WAITOK | M_ZERO); - if (!ch) - return NULL; ch->methods = kobj_create(cls, M_DEVBUF, M_WAITOK); if (!ch->methods) { @@ -590,9 +586,6 @@ pcm_chn_add(struct snddev_info *d, struct pcm_channel *ch) */ sce = kmalloc(sizeof(*sce), M_DEVBUF, M_WAITOK | M_ZERO); - if (!sce) { - return ENOMEM; - } snd_mtxlock(d->lock); sce->channel = ch; diff --git a/sys/dev/sound/pcm/vchan.c b/sys/dev/sound/pcm/vchan.c index 62071ba61b..c62e7ffce6 100644 --- a/sys/dev/sound/pcm/vchan.c +++ b/sys/dev/sound/pcm/vchan.c @@ -24,14 +24,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/vchan.c,v 1.17.2.5 2007/02/04 06:17:14 ariff Exp $ - * $DragonFly: src/sys/dev/sound/pcm/vchan.c,v 1.7 2007/06/16 19:48:05 hasso Exp $ + * $DragonFly: src/sys/dev/sound/pcm/vchan.c,v 1.8 2008/01/06 16:55:51 swildner Exp $ */ #include #include #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/vchan.c,v 1.7 2007/06/16 19:48:05 hasso Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/vchan.c,v 1.8 2008/01/06 16:55:51 swildner Exp $"); /* * Default speed @@ -161,8 +161,6 @@ vchan_init(kobj_t obj, void *devinfo, struct snd_dbuf *b, struct pcm_channel *c, KASSERT(dir == PCMDIR_PLAY, ("vchan_init: bad direction")); ch = kmalloc(sizeof(*ch), M_DEVBUF, M_WAITOK | M_ZERO); - if (!ch) - return NULL; ch->parent = parent; ch->channel = c; ch->fmt = AFMT_U8; @@ -406,10 +404,6 @@ vchan_create(struct pcm_channel *parent) CHN_UNLOCK(parent); pce = kmalloc(sizeof(*pce), M_DEVBUF, M_WAITOK | M_ZERO); - if (!pce) { - CHN_LOCK(parent); - return ENOMEM; - } /* create a new playback channel */ child = pcm_chn_create(d, parent, &vchan_class, PCMDIR_VIRTUAL, parent); diff --git a/sys/dev/usbmisc/uticom/uticom.c b/sys/dev/usbmisc/uticom/uticom.c index 74dd632a05..44c2a99b1b 100644 --- a/sys/dev/usbmisc/uticom/uticom.c +++ b/sys/dev/usbmisc/uticom/uticom.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/dev/usbmisc/uticom/uticom.c,v 1.1 2007/11/07 08:31:08 hasso Exp $ + * $DragonFly: src/sys/dev/usbmisc/uticom/uticom.c,v 1.2 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -914,12 +914,6 @@ static int uticom_download_fw(struct uticom_softc *sc, unsigned int pipeno, buffer_size = UTICOM_FW_BUFSZ + sizeof(struct uticom_fw_header); buffer = kmalloc(buffer_size, M_USBDEV, M_WAITOK); - if (!buffer) { - device_printf(sc->sc_ucom.sc_dev, - "uticom_download_fw: out of memory\n"); - return ENOMEM; - } - memcpy(buffer, firmware, firmware_size); memset(buffer + firmware_size, 0xff, buffer_size - firmware_size); diff --git a/sys/dev/video/ctx/ctx.c b/sys/dev/video/ctx/ctx.c index 61402dbdc5..2921f74617 100644 --- a/sys/dev/video/ctx/ctx.c +++ b/sys/dev/video/ctx/ctx.c @@ -9,7 +9,7 @@ * for damages incurred with its use. * * $FreeBSD: src/sys/i386/isa/ctx.c,v 1.36 2000/01/29 16:17:31 peter Exp $ - * $DragonFly: src/sys/dev/video/ctx/ctx.c,v 1.11 2006/09/10 01:26:37 dillon Exp $ + * $DragonFly: src/sys/dev/video/ctx/ctx.c,v 1.12 2008/01/06 16:55:51 swildner Exp $ */ /* @@ -221,8 +221,6 @@ ctxopen(struct dev_open_args *ap) /* get space for the LUT buffer */ sr->lutp = kmalloc(LUTSIZE, M_DEVBUF, M_WAITOK); - if (sr->lutp == NULL) - return (ENOMEM); sr->flag = OPEN; diff --git a/sys/kern/inflate.c b/sys/kern/inflate.c index 2490338320..e519cc5311 100644 --- a/sys/kern/inflate.c +++ b/sys/kern/inflate.c @@ -8,7 +8,7 @@ * ---------------------------------------------------------------------------- * * $FreeBSD: src/sys/kern/inflate.c,v 1.14 1999/12/29 04:54:39 peter Exp $ - * $DragonFly: src/sys/kern/inflate.c,v 1.7 2006/12/23 23:47:54 swildner Exp $ + * $DragonFly: src/sys/kern/inflate.c,v 1.8 2008/01/06 16:55:51 swildner Exp $ * * */ @@ -554,12 +554,7 @@ huft_build(struct inflate *glbl, unsigned *b, unsigned n, unsigned s, l[h] = j; /* set table size in stack */ /* allocate and link in new table */ - if ((q = (struct huft *) kmalloc((z + 1) * sizeof(struct huft), M_GZIP, M_WAITOK)) == - (struct huft *) NULL) { - if (h) - huft_free(glbl, u[0]); - return 3; /* not enough memory */ - } + q = (struct huft *) kmalloc((z + 1) * sizeof(struct huft), M_GZIP, M_WAITOK); glbl->gz_hufts += z + 1; /* track memory usage */ *t = q + 1; /* link to list for * huft_free() */ diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 6d5352f659..4ed14f28f7 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -40,7 +40,7 @@ * * @(#)init_main.c 8.9 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/init_main.c,v 1.134.2.8 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/kern/init_main.c,v 1.83 2007/11/19 18:49:06 swildner Exp $ + * $DragonFly: src/sys/kern/init_main.c,v 1.84 2008/01/06 16:55:51 swildner Exp $ */ #include "opt_init_path.h" @@ -131,8 +131,6 @@ sysinit_add(struct sysinit **set, struct sysinit **set_end) else count += sysinit_end - sysinit; newset = kmalloc(count * sizeof(*sipp), M_TEMP, M_WAITOK); - if (newset == NULL) - panic("cannot malloc for sysinit"); xipp = newset; if (newsysinit) { for (sipp = newsysinit; sipp < newsysinit_end; sipp++) diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index d1bd13f693..3d8e0718c7 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_exec.c,v 1.107.2.15 2002/07/30 15:40:46 nectar Exp $ - * $DragonFly: src/sys/kern/kern_exec.c,v 1.62 2007/08/28 01:09:24 dillon Exp $ + * $DragonFly: src/sys/kern/kern_exec.c,v 1.63 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -1030,8 +1030,6 @@ exec_register(const struct execsw *execsw_arg) for (es = execsw; *es; es++) count++; newexecsw = kmalloc(count * sizeof(*es), M_TEMP, M_WAITOK); - if (newexecsw == NULL) - return ENOMEM; xs = newexecsw; if (execsw) for (es = execsw; *es; es++) @@ -1063,8 +1061,6 @@ exec_unregister(const struct execsw *execsw_arg) if (*es != execsw_arg) count++; newexecsw = kmalloc(count * sizeof(*es), M_TEMP, M_WAITOK); - if (newexecsw == NULL) - return ENOMEM; xs = newexecsw; for (es = execsw; *es; es++) if (*es != execsw_arg) diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c index 32cd35d5a1..1c510d65bf 100644 --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_linker.c,v 1.41.2.3 2001/11/21 17:50:35 luigi Exp $ - * $DragonFly: src/sys/kern/kern_linker.c,v 1.40 2008/01/05 14:02:38 swildner Exp $ + * $DragonFly: src/sys/kern/kern_linker.c,v 1.41 2008/01/06 16:55:51 swildner Exp $ */ #include "opt_ddb.h" @@ -260,10 +260,6 @@ linker_load_file(const char* filename, linker_file_t* result) } koname = kmalloc(strlen(filename) + 4, M_LINKER, M_WAITOK); - if (koname == NULL) { - error = ENOMEM; - goto out; - } ksprintf(koname, "%s.ko", filename); lf = NULL; foundfile = 0; @@ -324,8 +320,6 @@ linker_find_file_by_name(const char* filename) filename += i; koname = kmalloc(strlen(filename) + 4, M_LINKER, M_WAITOK); - if (koname == NULL) - goto out; ksprintf(koname, "%s.ko", filename); lockmgr(&lock, LK_SHARED); @@ -337,7 +331,6 @@ linker_find_file_by_name(const char* filename) } lockmgr(&lock, LK_RELEASE); -out: if (koname) kfree(koname, M_LINKER); return lf; @@ -374,8 +367,6 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops) lockmgr(&lock, LK_EXCLUSIVE); namelen = strlen(filename) + 1; lf = kmalloc(sizeof(struct linker_file) + namelen, M_LINKER, M_WAITOK); - if (!lf) - goto out; bzero(lf, sizeof(*lf)); lf->refs = 1; @@ -393,7 +384,6 @@ linker_make_file(const char* pathname, void* priv, struct linker_file_ops* ops) lf->ops = ops; TAILQ_INSERT_TAIL(&linker_files, lf, link); -out: lockmgr(&lock, LK_RELEASE); return lf; } @@ -499,8 +489,6 @@ linker_file_add_dependancy(linker_file_t file, linker_file_t dep) newdeps = kmalloc((file->ndeps + 1) * sizeof(linker_file_t*), M_LINKER, M_WAITOK | M_ZERO); - if (newdeps == NULL) - return ENOMEM; if (file->deps) { bcopy(file->deps, newdeps, file->ndeps * sizeof(linker_file_t*)); @@ -606,10 +594,6 @@ linker_file_lookup_symbol(linker_file_t file, const char* name, int deps, caddr_ + common_size + strlen(name) + 1, M_LINKER, M_WAITOK | M_ZERO); - if (!cp) { - KLD_DPF(SYM, ("linker_file_lookup_symbol: nomem\n")); - return ENOMEM; - } cp->address = (caddr_t) (cp + 1); cp->name = cp->address + common_size; @@ -1098,8 +1082,8 @@ linker_strdup(const char *str) { char *result; - if ((result = kmalloc((strlen(str) + 1), M_LINKER, M_WAITOK)) != NULL) - strcpy(result, str); + result = kmalloc(strlen(str) + 1, M_LINKER, M_WAITOK); + strcpy(result, str); return(result); } diff --git a/sys/kern/kern_module.c b/sys/kern/kern_module.c index d5da2d11bd..dd5c73990f 100644 --- a/sys/kern/kern_module.c +++ b/sys/kern/kern_module.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/kern_module.c,v 1.21 1999/11/08 06:53:30 peter Exp $ - * $DragonFly: src/sys/kern/kern_module.c,v 1.14 2007/04/30 07:18:53 dillon Exp $ + * $DragonFly: src/sys/kern/kern_module.c,v 1.15 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -130,8 +130,6 @@ module_register(const moduledata_t *data, linker_file_t container) namelen = strlen(data->name) + 1; newmod = (module_t) kmalloc(sizeof(struct module) + namelen, M_MODULE, M_WAITOK); - if (newmod == 0) - return ENOMEM; newmod->refs = 1; newmod->id = nextid++; diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c index 75e2e1abcf..23a2e4ee32 100644 --- a/sys/kern/kern_sysctl.c +++ b/sys/kern/kern_sysctl.c @@ -38,7 +38,7 @@ * * @(#)kern_sysctl.c 8.4 (Berkeley) 4/14/94 * $FreeBSD: src/sys/kern/kern_sysctl.c,v 1.92.2.9 2003/05/01 22:48:09 trhodes Exp $ - * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.28 2007/09/03 17:32:32 dillon Exp $ + * $DragonFly: src/sys/kern/kern_sysctl.c,v 1.29 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -443,8 +443,7 @@ sysctl_add_oid(struct sysctl_ctx_list *clist, struct sysctl_oid_list *parent, if (descr) { int len = strlen(descr) + 1; oidp->oid_descr = kmalloc(len, M_SYSCTLOID, M_WAITOK); - if (oidp->oid_descr) - strcpy((char *)(uintptr_t)(const void *)oidp->oid_descr, descr); + strcpy((char *)(uintptr_t)(const void *)oidp->oid_descr, descr); }; /* Update the context, if used */ if (clist != NULL) diff --git a/sys/kern/sysv_msg.c b/sys/kern/sysv_msg.c index fa2581f653..574cc724be 100644 --- a/sys/kern/sysv_msg.c +++ b/sys/kern/sysv_msg.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/kern/sysv_msg.c,v 1.23.2.5 2002/12/31 08:54:53 maxim Exp $ */ -/* $DragonFly: src/sys/kern/sysv_msg.c,v 1.17 2006/12/23 23:47:54 swildner Exp $ */ +/* $DragonFly: src/sys/kern/sysv_msg.c,v 1.18 2008/01/06 16:55:51 swildner Exp $ */ /* * Implementation of SVID messages @@ -130,17 +130,9 @@ msginit(void *dummy) msginfo.msgmax = msginfo.msgseg * msginfo.msgssz; msgpool = kmalloc(msginfo.msgmax, M_MSG, M_WAITOK); - if (msgpool == NULL) - panic("msgpool is NULL"); msgmaps = kmalloc(sizeof(struct msgmap) * msginfo.msgseg, M_MSG, M_WAITOK); - if (msgmaps == NULL) - panic("msgmaps is NULL"); msghdrs = kmalloc(sizeof(struct msg) * msginfo.msgtql, M_MSG, M_WAITOK); - if (msghdrs == NULL) - panic("msghdrs is NULL"); msqids = kmalloc(sizeof(struct msqid_ds) * msginfo.msgmni, M_MSG, M_WAITOK); - if (msqids == NULL) - panic("msqids is NULL"); /* * msginfo.msgssz should be a power of two for efficiency reasons. diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c index 204a66403d..f207bfcff7 100644 --- a/sys/kern/sysv_sem.c +++ b/sys/kern/sysv_sem.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/kern/sysv_sem.c,v 1.69 2004/03/17 09:37:13 cperciva Exp $ */ -/* $DragonFly: src/sys/kern/sysv_sem.c,v 1.18 2006/12/23 23:47:54 swildner Exp $ */ +/* $DragonFly: src/sys/kern/sysv_sem.c,v 1.19 2008/01/06 16:55:51 swildner Exp $ */ /* * Implementation of SVID semaphores @@ -166,14 +166,8 @@ seminit(void *dummy) int i; sem = kmalloc(sizeof(struct sem) * seminfo.semmns, M_SEM, M_WAITOK); - if (sem == NULL) - panic("sem is NULL"); sema = kmalloc(sizeof(struct semid_ds) * seminfo.semmni, M_SEM, M_WAITOK); - if (sema == NULL) - panic("sema is NULL"); semu = kmalloc(seminfo.semmnu * seminfo.semusz, M_SEM, M_WAITOK); - if (semu == NULL) - panic("semu is NULL"); for (i = 0; i < seminfo.semmni; i++) { sema[i].sem_base = 0; diff --git a/sys/kern/sysv_shm.c b/sys/kern/sysv_shm.c index 794a0a369e..3d1b8a26c7 100644 --- a/sys/kern/sysv_shm.c +++ b/sys/kern/sysv_shm.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/kern/sysv_shm.c,v 1.45.2.6 2002/10/22 20:45:03 fjoe Exp $ */ -/* $DragonFly: src/sys/kern/sysv_shm.c,v 1.20 2006/12/23 23:47:54 swildner Exp $ */ +/* $DragonFly: src/sys/kern/sysv_shm.c,v 1.21 2008/01/06 16:55:51 swildner Exp $ */ /* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */ /* @@ -630,8 +630,6 @@ shmrealloc(void) return; newsegs = kmalloc(shminfo.shmmni * sizeof(*newsegs), M_SHM, M_WAITOK); - if (newsegs == NULL) - return; for (i = 0; i < shmalloced; i++) bcopy(&shmsegs[i], &newsegs[i], sizeof(newsegs[0])); for (; i < shminfo.shmmni; i++) { @@ -651,8 +649,6 @@ shminit(void *dummy) shminfo.shmmax = shminfo.shmall * PAGE_SIZE; shmalloced = shminfo.shmmni; shmsegs = kmalloc(shmalloced * sizeof(shmsegs[0]), M_SHM, M_WAITOK); - if (shmsegs == NULL) - panic("cannot allocate initial memory for sysvshm"); for (i = 0; i < shmalloced; i++) { shmsegs[i].shm_perm.mode = SHMSEG_FREE; shmsegs[i].shm_perm.seq = 0; diff --git a/sys/kern/uipc_usrreq.c b/sys/kern/uipc_usrreq.c index 903fcbe94c..c2df6b4a2c 100644 --- a/sys/kern/uipc_usrreq.c +++ b/sys/kern/uipc_usrreq.c @@ -32,7 +32,7 @@ * * From: @(#)uipc_usrreq.c 8.3 (Berkeley) 1/4/94 * $FreeBSD: src/sys/kern/uipc_usrreq.c,v 1.54.2.10 2003/03/04 17:28:09 nectar Exp $ - * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.36 2007/08/13 17:43:55 dillon Exp $ + * $DragonFly: src/sys/kern/uipc_usrreq.c,v 1.37 2008/01/06 16:55:51 swildner Exp $ */ #include @@ -848,8 +848,6 @@ unp_pcblist(SYSCTL_HANDLER_ARGS) n = unp_count; unp_list = kmalloc(n * sizeof *unp_list, M_TEMP, M_WAITOK); - if (unp_list == NULL) - return ENOMEM; for (unp = LIST_FIRST(head), i = 0; unp && i < n; unp = LIST_NEXT(unp, unp_link)) { diff --git a/sys/net/bridge/if_bridge.c b/sys/net/bridge/if_bridge.c index 87c55a481b..229719f367 100644 --- a/sys/net/bridge/if_bridge.c +++ b/sys/net/bridge/if_bridge.c @@ -66,7 +66,7 @@ * $OpenBSD: if_bridge.c,v 1.60 2001/06/15 03:38:33 itojun Exp $ * $NetBSD: if_bridge.c,v 1.31 2005/06/01 19:45:34 jdc Exp $ * $FreeBSD: src/sys/net/if_bridge.c,v 1.26 2005/10/13 23:05:55 thompsa Exp $ - * $DragonFly: src/sys/net/bridge/if_bridge.c,v 1.26 2007/11/27 11:15:30 sephe Exp $ + * $DragonFly: src/sys/net/bridge/if_bridge.c,v 1.27 2008/01/06 16:55:52 swildner Exp $ */ /* @@ -1240,8 +1240,6 @@ bridge_ioctl_addspan(struct bridge_softc *sc, void *arg) } bif = kmalloc(sizeof(*bif), M_DEVBUF, M_WAITOK|M_ZERO); - if (bif == NULL) - return (ENOMEM); bif->bif_ifp = ifs; bif->bif_flags = IFBIF_SPAN; diff --git a/sys/net/ef/if_ef.c b/sys/net/ef/if_ef.c index 02b487eaeb..f0481828a5 100644 --- a/sys/net/ef/if_ef.c +++ b/sys/net/ef/if_ef.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/net/if_ef.c,v 1.2.2.4 2001/02/22 09:27:04 bp Exp $ - * $DragonFly: src/sys/net/ef/if_ef.c,v 1.24 2008/01/05 14:02:38 swildner Exp $ + * $DragonFly: src/sys/net/ef/if_ef.c,v 1.25 2008/01/06 16:55:52 swildner Exp $ */ #include "opt_inet.h" @@ -478,8 +478,6 @@ ef_clone(struct ef_link *efl, int ft) efp = (struct efnet*)kmalloc(sizeof(struct efnet), M_IFADDR, M_WAITOK | M_ZERO); - if (efp == NULL) - return ENOMEM; efp->ef_ifp = ifp; efp->ef_frametype = ft; eifp = &efp->ef_ac.ac_if; @@ -507,10 +505,6 @@ ef_load(void) EFDEBUG("Found interface %s\n", ifp->if_xname); efl = (struct ef_link*)kmalloc(sizeof(struct ef_link), M_IFADDR, M_WAITOK | M_ZERO); - if (efl == NULL) { - error = ENOMEM; - break; - } efl->el_ifp = ifp; #ifdef ETHER_II diff --git a/sys/net/i4b/driver/i4b_ipr.c b/sys/net/i4b/driver/i4b_ipr.c index e324a5fa45..a306ba6625 100644 --- a/sys/net/i4b/driver/i4b_ipr.c +++ b/sys/net/i4b/driver/i4b_ipr.c @@ -28,7 +28,7 @@ * --------------------------------------------------------- * * $FreeBSD: src/sys/i4b/driver/i4b_ipr.c,v 1.8.2.3 2001/10/27 15:48:17 hm Exp $ - * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.20 2006/12/22 23:44:55 swildner Exp $ + * $DragonFly: src/sys/net/i4b/driver/i4b_ipr.c,v 1.21 2008/01/06 16:55:52 swildner Exp $ * * last edit-date: [Fri Oct 26 19:32:38 2001] * @@ -275,11 +275,8 @@ i4biprattach(void *dummy) sl_compress_init(&sc->sc_compr, -1); #ifdef IPR_VJ_USEBUFFER - if(!((sc->sc_cbuf = - (u_char *)kmalloc(I4BIPRMAXMTU+128, M_DEVBUF, M_WAITOK)))) - { - panic("if_ipr.c, ipr_attach: VJ malloc failed"); - } + sc->sc_cbuf = (u_char *)kmalloc(I4BIPRMAXMTU+128, M_DEVBUF, + M_WAITOK); #endif #endif sc->sc_updown = SOFT_ENA; /* soft enabled */ diff --git a/sys/net/i4b/layer4/i4b_i4bdrv.c b/sys/net/i4b/layer4/i4b_i4bdrv.c index bb96bffee1..eea71f4a67 100644 --- a/sys/net/i4b/layer4/i4b_i4bdrv.c +++ b/sys/net/i4b/layer4/i4b_i4bdrv.c @@ -28,7 +28,7 @@ * -------------------------------------------- * * $FreeBSD: src/sys/i4b/layer4/i4b_i4bdrv.c,v 1.11.2.5 2001/12/16 15:12:59 hm Exp $ - * $DragonFly: src/sys/net/i4b/layer4/i4b_i4bdrv.c,v 1.19 2006/12/22 23:44:56 swildner Exp $ + * $DragonFly: src/sys/net/i4b/layer4/i4b_i4bdrv.c,v 1.20 2008/01/06 16:55:52 swildner Exp $ * * last edit-date: [Sat Aug 11 18:08:10 2001] * @@ -642,12 +642,6 @@ i4bioctl(struct dev_ioctl_args *ap) prots2 = kmalloc(r->numprotos * sizeof(struct isdn_dr_prot), M_DEVBUF, M_WAITOK); - if(!prots || !prots2) - { - error = ENOMEM; - goto download_done; - } - copyin(r->protocols, prots, r->numprotos * sizeof(struct isdn_dr_prot)); for(i = 0; i < r->numprotos; i++) @@ -714,27 +708,14 @@ download_done: req.in_param = kmalloc(r->in_param_len, M_DEVBUF, M_WAITOK); - if(!req.in_param) - { - error = ENOMEM; - goto diag_done; - } error = copyin(r->in_param, req.in_param, req.in_param_len); if (error) goto diag_done; } if(req.out_param_len) - { req.out_param = kmalloc(r->out_param_len, M_DEVBUF, M_WAITOK); - if(!req.out_param) - { - error = ENOMEM; - goto diag_done; - } - } - error = ctrl_desc[r->controller].N_DIAGNOSTICS(r->controller, &req); if(!error && req.out_param_len) diff --git a/sys/net/ppp/if_ppp.c b/sys/net/ppp/if_ppp.c index 1065ef52af..812d35ab45 100644 --- a/sys/net/ppp/if_ppp.c +++ b/sys/net/ppp/if_ppp.c @@ -70,7 +70,7 @@ */ /* $FreeBSD: src/sys/net/if_ppp.c,v 1.67.2.4 2002/04/14 21:41:48 luigi Exp $ */ -/* $DragonFly: src/sys/net/ppp/if_ppp.c,v 1.36 2007/08/24 16:00:52 dillon Exp $ */ +/* $DragonFly: src/sys/net/ppp/if_ppp.c,v 1.37 2008/01/06 16:55:52 swildner Exp $ */ /* from if_sl.c,v 1.11 84/10/04 12:54:47 rick Exp */ /* from NetBSD: if_ppp.c,v 1.15.2.2 1994/07/28 05:17:58 cgd Exp */ @@ -545,9 +545,6 @@ pppioctl(struct ppp_softc *sc, u_long cmd, caddr_t data, newcodelen = nbp->bf_len * sizeof(struct bpf_insn); if (newcodelen != 0) { MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK); - if (newcode == 0) { - return EINVAL; /* or sumpin */ - } if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode, newcodelen)) != 0) { kfree(newcode, M_DEVBUF); diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 81e456fc71..9e9cb1bf86 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -64,7 +64,7 @@ * * @(#)rtsock.c 8.7 (Berkeley) 10/12/95 * $FreeBSD: src/sys/net/rtsock.c,v 1.44.2.11 2002/12/04 14:05:41 ru Exp $ - * $DragonFly: src/sys/net/rtsock.c,v 1.41 2007/12/19 11:00:22 sephe Exp $ + * $DragonFly: src/sys/net/rtsock.c,v 1.42 2008/01/06 16:55:51 swildner Exp $ */ #include "opt_sctp.h" @@ -149,8 +149,6 @@ rts_attach(struct socket *so, int proto, struct pru_attach_info *ai) return EISCONN; /* XXX panic? */ rp = kmalloc(sizeof *rp, M_PCB, M_WAITOK | M_ZERO); - if (rp == NULL) - return ENOBUFS; /* * The critical section is necessary to block protocols from sending diff --git a/sys/netgraph/eiface/ng_eiface.c b/sys/netgraph/eiface/ng_eiface.c index 779c23f46e..5e57e90888 100644 --- a/sys/netgraph/eiface/ng_eiface.c +++ b/sys/netgraph/eiface/ng_eiface.c @@ -28,7 +28,7 @@ * * $Id: ng_eiface.c,v 1.14 2000/03/15 12:28:44 vitaly Exp $ * $FreeBSD: src/sys/netgraph/ng_eiface.c,v 1.4.2.5 2002/12/17 21:47:48 julian Exp $ - * $DragonFly: src/sys/netgraph/eiface/ng_eiface.c,v 1.15 2008/01/05 14:02:39 swildner Exp $ + * $DragonFly: src/sys/netgraph/eiface/ng_eiface.c,v 1.16 2008/01/06 16:55:52 swildner Exp $ */ #include @@ -317,8 +317,6 @@ ng_eiface_constructor(node_p *nodep) /* Allocate node and interface private structures */ MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH, M_WAITOK | M_ZERO); - if (priv == NULL) - return (ENOMEM); ifp = &(priv->arpcom.ac_if); diff --git a/sys/netgraph/socket/ng_socket.c b/sys/netgraph/socket/ng_socket.c index 0c67418428..d4826e57da 100644 --- a/sys/netgraph/socket/ng_socket.c +++ b/sys/netgraph/socket/ng_socket.c @@ -37,7 +37,7 @@ * Author: Julian Elischer * * $FreeBSD: src/sys/netgraph/ng_socket.c,v 1.11.2.6 2002/07/02 22:17:18 archie Exp $ - * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.15 2008/01/05 14:02:40 swildner Exp $ + * $DragonFly: src/sys/netgraph/socket/ng_socket.c,v 1.16 2008/01/06 16:55:52 swildner Exp $ * $Whistle: ng_socket.c,v 1.28 1999/11/01 09:24:52 julian Exp $ */ @@ -219,10 +219,6 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, * the sockaddr header, and make sure it's NUL terminated */ len = sap->sg_len - 2; MALLOC(path, char *, len + 1, M_NETGRAPH, M_WAITOK); - if (path == NULL) { - error = ENOMEM; - goto release; - } bcopy(sap->sg_data, path, len); path[len] = '\0'; @@ -234,10 +230,6 @@ ngc_send(struct socket *so, int flags, struct mbuf *m, struct sockaddr *addr, /* Move the data into a linear buffer as well. Messages are not * delivered in mbufs. */ MALLOC(msg, char *, len + 1, M_NETGRAPH, M_WAITOK); - if (msg == NULL) { - error = ENOMEM; - goto release; - } m_copydata(m, 0, len, msg); /* The callee will free the msg when done. The addr is our business. */ @@ -441,10 +433,6 @@ ng_attach_cntl(struct socket *so) /* Allocate node private info */ MALLOC(privdata, struct ngsock *, sizeof(*privdata), M_NETGRAPH, M_WAITOK | M_ZERO); - if (privdata == NULL) { - ng_detach_common(pcbp, NG_CONTROL); - return (ENOMEM); - } /* Make the generic node components */ if ((error = ng_make_node_common(&typestruct, &privdata->node)) != 0) { @@ -484,8 +472,6 @@ ng_attach_common(struct socket *so, int type) /* Allocate the pcb */ MALLOC(pcbp, struct ngpcb *, sizeof(*pcbp), M_PCB, M_WAITOK | M_ZERO); - if (pcbp == NULL) - return (ENOMEM); pcbp->type = type; /* Link the pcb and the socket */ diff --git a/sys/netgraph/tty/ng_tty.c b/sys/netgraph/tty/ng_tty.c index fe313f7a5d..6688d1ca79 100644 --- a/sys/netgraph/tty/ng_tty.c +++ b/sys/netgraph/tty/ng_tty.c @@ -37,7 +37,7 @@ * Author: Archie Cobbs * * $FreeBSD: src/sys/netgraph/ng_tty.c,v 1.7.2.3 2002/02/13 00:43:12 dillon Exp $ - * $DragonFly: src/sys/netgraph/tty/ng_tty.c,v 1.18 2008/01/05 14:02:40 swildner Exp $ + * $DragonFly: src/sys/netgraph/tty/ng_tty.c,v 1.19 2008/01/06 16:55:52 swildner Exp $ * $Whistle: ng_tty.c,v 1.21 1999/11/01 09:24:52 julian Exp $ */ @@ -206,10 +206,6 @@ ngt_open(cdev_t dev, struct tty *tp) /* Initialize private struct */ MALLOC(sc, sc_p, sizeof(*sc), M_NETGRAPH, M_WAITOK | M_ZERO); - if (sc == NULL) { - error = ENOMEM; - goto done; - } sc->tp = tp; sc->hotchar = NG_TTY_DFL_HOTCHAR; sc->qtail = &sc->qhead; diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index c9ea424b1c..e3806763cd 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -25,7 +25,7 @@ */ /* * $FreeBSD: src/sys/netinet/ip_carp.c,v 1.48 2007/02/02 09:39:09 glebius Exp $ - * $DragonFly: src/sys/netinet/ip_carp.c,v 1.4 2007/10/20 10:28:44 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_carp.c,v 1.5 2008/01/06 16:55:52 swildner Exp $ */ #include "opt_carp.h" @@ -360,11 +360,6 @@ carp_clone_create(struct if_clone *ifc, int unit) MALLOC(sc, struct carp_softc *, sizeof(*sc), M_CARP, M_WAITOK|M_ZERO); ifp = SC2IFP(sc) = kmalloc(sizeof(struct ifnet), M_IFNET, M_WAITOK|M_ZERO); - if (ifp == NULL) { - FREE(sc, M_CARP); - return (ENOSPC); - } - sc->sc_flags_backup = 0; sc->sc_suppress = 0; sc->sc_advbase = CARP_DFLTINTV; @@ -1476,10 +1471,6 @@ carp_set_addr(struct carp_softc *sc, struct sockaddr_in *sin) MALLOC(cif, struct carp_if *, sizeof(*cif), M_CARP, M_WAITOK|M_ZERO); - if (!cif) { - error = ENOBUFS; - goto cleanup; - } if ((error = ifpromisc(ifp, 1))) { FREE(cif, M_CARP); goto cleanup; @@ -1664,10 +1655,6 @@ carp_set_addr6(struct carp_softc *sc, struct sockaddr_in6 *sin6) if (!ifp->if_carp) { MALLOC(cif, struct carp_if *, sizeof(*cif), M_CARP, M_WAITOK|M_ZERO); - if (!cif) { - error = ENOBUFS; - goto cleanup; - } if ((error = ifpromisc(ifp, 1))) { FREE(cif, M_CARP); goto cleanup; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index 5e8f1c7701..9278ffa853 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -28,7 +28,7 @@ * * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/netinet/ip_output.c,v 1.99.2.37 2003/04/15 06:44:45 silby Exp $ - * $DragonFly: src/sys/netinet/ip_output.c,v 1.40 2007/12/28 13:27:45 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_output.c,v 1.41 2008/01/06 16:55:52 swildner Exp $ */ #define _IP_VHL @@ -1817,8 +1817,6 @@ ip_setmoptions(struct sockopt *sopt, struct ip_moptions **imop) */ imo = kmalloc(sizeof *imo, M_IPMOPTS, M_WAITOK); - if (imo == NULL) - return (ENOBUFS); *imop = imo; imo->imo_multicast_ifp = NULL; imo->imo_multicast_addr.s_addr = INADDR_ANY; diff --git a/sys/netinet/sctp_pcb.c b/sys/netinet/sctp_pcb.c index 5e394ad065..a966f0bfae 100644 --- a/sys/netinet/sctp_pcb.c +++ b/sys/netinet/sctp_pcb.c @@ -1,5 +1,5 @@ /* $KAME: sctp_pcb.c,v 1.37 2004/08/17 06:28:02 t-momose Exp $ */ -/* $DragonFly: src/sys/netinet/sctp_pcb.c,v 1.12 2007/04/22 01:13:14 dillon Exp $ */ +/* $DragonFly: src/sys/netinet/sctp_pcb.c,v 1.13 2008/01/06 16:55:52 swildner Exp $ */ /* * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. @@ -5031,9 +5031,6 @@ sctp_initiate_iterator(asoc_func af, uint32_t pcb_state, uint32_t asoc_state, } MALLOC(it, struct sctp_iterator *, sizeof(struct sctp_iterator), M_PCB, M_WAITOK); - if (it == NULL) { - return (ENOMEM); - } memset(it, 0, sizeof(*it)); it->function_toapply = af; it->function_atend = ef; diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index a4fe75f201..e9bd88c439 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netinet6/ip6_output.c,v 1.13.2.18 2003/01/24 05:11:35 sam Exp $ */ -/* $DragonFly: src/sys/netinet6/ip6_output.c,v 1.32 2006/12/22 23:57:53 swildner Exp $ */ +/* $DragonFly: src/sys/netinet6/ip6_output.c,v 1.33 2008/01/06 16:55:52 swildner Exp $ */ /* $KAME: ip6_output.c,v 1.279 2002/01/26 06:12:30 jinmei Exp $ */ /* @@ -1890,8 +1890,6 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m) im6o = (struct ip6_moptions *) kmalloc(sizeof(*im6o), M_IPMOPTS, M_WAITOK); - if (im6o == NULL) - return (ENOBUFS); *im6op = im6o; im6o->im6o_multicast_ifp = NULL; im6o->im6o_multicast_hlim = ip6_defmcasthlim; @@ -2059,10 +2057,6 @@ ip6_setmoptions(int optname, struct ip6_moptions **im6op, struct mbuf *m) * address list for the given interface. */ imm = kmalloc(sizeof(*imm), M_IPMADDR, M_WAITOK); - if (imm == NULL) { - error = ENOBUFS; - break; - } if ((imm->i6mm_maddr = in6_addmulti(&mreq->ipv6mr_multiaddr, ifp, &error)) == NULL) { kfree(imm, M_IPMADDR); diff --git a/sys/netproto/atm/atm_socket.c b/sys/netproto/atm/atm_socket.c index eb7b4dbff9..1581de6fc2 100644 --- a/sys/netproto/atm/atm_socket.c +++ b/sys/netproto/atm/atm_socket.c @@ -24,7 +24,7 @@ * notice must be reproduced on all copies. * * @(#) $FreeBSD: src/sys/netatm/atm_socket.c,v 1.4 1999/08/28 00:48:37 peter Exp $ - * @(#) $DragonFly: src/sys/netproto/atm/atm_socket.c,v 1.10 2007/04/22 01:13:15 dillon Exp $ + * @(#) $DragonFly: src/sys/netproto/atm/atm_socket.c,v 1.11 2008/01/06 16:55:52 swildner Exp $ */ /* @@ -556,8 +556,6 @@ atm_sock_sockaddr(struct socket *so, struct sockaddr **addr) * Return local interface address, if known */ satm = KM_ALLOC(sizeof *satm, M_SONAME, M_WAITOK); - if (satm == NULL) - return (ENOMEM); KM_ZERO(satm, sizeof(*satm)); satm->satm_family = AF_ATM; @@ -613,8 +611,6 @@ atm_sock_peeraddr(struct socket *so, struct sockaddr **addr) * Return remote address, if known */ satm = KM_ALLOC(sizeof *satm, M_SONAME, M_WAITOK); - if (satm == NULL) - return (ENOMEM); KM_ZERO(satm, sizeof(*satm)); satm->satm_family = AF_ATM; diff --git a/sys/netproto/ipsec/keysock.c b/sys/netproto/ipsec/keysock.c index 5fb793767d..dfec569030 100644 --- a/sys/netproto/ipsec/keysock.c +++ b/sys/netproto/ipsec/keysock.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netipsec/keysock.c,v 1.3.2.1 2003/01/24 05:11:36 sam Exp $ */ -/* $DragonFly: src/sys/netproto/ipsec/keysock.c,v 1.17 2007/04/22 01:13:15 dillon Exp $ */ +/* $DragonFly: src/sys/netproto/ipsec/keysock.c,v 1.18 2008/01/06 16:55:52 swildner Exp $ */ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ /* @@ -374,8 +374,6 @@ key_attach(struct socket *so, int proto, struct pru_attach_info *ai) if (sotorawcb(so) != 0) return EISCONN; /* XXX panic? */ kp = (struct keycb *)kmalloc(sizeof *kp, M_PCB, M_WAITOK|M_ZERO); /* XXX */ - if (kp == 0) - return ENOBUFS; /* * The critical section is necessary to block protocols from sending diff --git a/sys/netproto/ipsec/xform_esp.c b/sys/netproto/ipsec/xform_esp.c index 855521ce8d..282c26a14d 100644 --- a/sys/netproto/ipsec/xform_esp.c +++ b/sys/netproto/ipsec/xform_esp.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netipsec/xform_esp.c,v 1.2.2.2 2003/02/26 00:14:05 sam Exp $ */ -/* $DragonFly: src/sys/netproto/ipsec/xform_esp.c,v 1.12 2006/10/12 01:32:51 hsu Exp $ */ +/* $DragonFly: src/sys/netproto/ipsec/xform_esp.c,v 1.13 2008/01/06 16:55:52 swildner Exp $ */ /* $OpenBSD: ip_esp.c,v 1.69 2001/06/26 06:18:59 angelos Exp $ */ /* * The authors of this code are John Ioannidis (ji@tla.org), @@ -192,10 +192,6 @@ esp_init(struct secasvar *sav, struct xformsw *xsp) */ sav->ivlen = (txform == &enc_xform_null ? 0 : txform->blocksize); sav->iv = (caddr_t) kmalloc(sav->ivlen, M_XDATA, M_WAITOK); - if (sav->iv == NULL) { - DPRINTF(("esp_init: no memory for IV\n")); - return EINVAL; - } key_randomfill(sav->iv, sav->ivlen); /*XXX*/ /* diff --git a/sys/netproto/ipx/ipx.c b/sys/netproto/ipx/ipx.c index 1225010796..545312607a 100644 --- a/sys/netproto/ipx/ipx.c +++ b/sys/netproto/ipx/ipx.c @@ -34,7 +34,7 @@ * @(#)ipx.c * * $FreeBSD: src/sys/netipx/ipx.c,v 1.17.2.3 2003/04/04 09:35:43 tjr Exp $ - * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.13 2006/12/22 23:57:54 swildner Exp $ + * $DragonFly: src/sys/netproto/ipx/ipx.c,v 1.14 2008/01/06 16:55:52 swildner Exp $ */ #include @@ -130,8 +130,6 @@ ipx_control(struct socket *so, u_long cmd, caddr_t data, oia = (struct ipx_ifaddr *) kmalloc(sizeof(*ia), M_IFADDR, M_WAITOK | M_ZERO); - if (oia == NULL) - return (ENOBUFS); if ((ia = ipx_ifaddr) != NULL) { for ( ; ia->ia_next != NULL; ia = ia->ia_next) ; diff --git a/sys/netproto/key/keysock.c b/sys/netproto/key/keysock.c index 14ad669ad5..73009dc7f6 100644 --- a/sys/netproto/key/keysock.c +++ b/sys/netproto/key/keysock.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/netkey/keysock.c,v 1.1.2.4 2003/01/11 19:10:59 ume Exp $ */ -/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.19 2008/01/05 14:02:40 swildner Exp $ */ +/* $DragonFly: src/sys/netproto/key/keysock.c,v 1.20 2008/01/06 16:55:52 swildner Exp $ */ /* $KAME: keysock.c,v 1.25 2001/08/13 20:07:41 itojun Exp $ */ /* @@ -384,8 +384,6 @@ key_attach(struct socket *so, int proto, struct pru_attach_info *ai) if (sotorawcb(so) != 0) return EISCONN; /* XXX panic? */ kp = (struct keycb *)kmalloc(sizeof *kp, M_PCB, M_WAITOK | M_ZERO); /* XXX */ - if (kp == 0) - return ENOBUFS; /* * The critical section is necessary to block protocols from sending diff --git a/sys/netproto/ns/ns.c b/sys/netproto/ns/ns.c index 85a72f4fdc..8c46eedadb 100644 --- a/sys/netproto/ns/ns.c +++ b/sys/netproto/ns/ns.c @@ -32,7 +32,7 @@ * * @(#)ns.c 8.2 (Berkeley) 11/15/93 * $FreeBSD: src/sys/netns/ns.c,v 1.9 1999/08/28 00:49:47 peter Exp $ - * $DragonFly: src/sys/netproto/ns/ns.c,v 1.15 2008/01/05 14:02:40 swildner Exp $ + * $DragonFly: src/sys/netproto/ns/ns.c,v 1.16 2008/01/06 16:55:52 swildner Exp $ */ #include @@ -136,8 +136,6 @@ ns_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp, if (ia == (struct ns_ifaddr *)0) { oia = (struct ns_ifaddr *) kmalloc(sizeof *ia, M_IFADDR, M_WAITOK | M_ZERO); - if (oia == (struct ns_ifaddr *)NULL) - return (ENOBUFS); if ((ia = ns_ifaddr) != NULL) { for ( ; ia->ia_next; ia = ia->ia_next) ; diff --git a/sys/netproto/smb/smb_rq.c b/sys/netproto/smb/smb_rq.c index c90ccdaf2e..c64a0c9869 100644 --- a/sys/netproto/smb/smb_rq.c +++ b/sys/netproto/smb/smb_rq.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_rq.c,v 1.1.2.2 2002/04/23 03:45:01 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.10 2006/09/05 00:55:49 dillon Exp $ + * $DragonFly: src/sys/netproto/smb/smb_rq.c,v 1.11 2008/01/06 16:55:53 swildner Exp $ */ #include #include @@ -68,8 +68,6 @@ smb_rq_alloc(struct smb_connobj *layer, u_char cmd, struct smb_cred *scred, int error; MALLOC(rqp, struct smb_rq *, sizeof(*rqp), M_SMBRQ, M_WAITOK); - if (rqp == NULL) - return ENOMEM; error = smb_rq_init(rqp, layer, cmd, scred); rqp->sr_flags |= SMBR_ALLOCED; if (error) { @@ -366,8 +364,6 @@ smb_t2_alloc(struct smb_connobj *layer, u_short setup, struct smb_cred *scred, int error; MALLOC(t2p, struct smb_t2rq *, sizeof(*t2p), M_SMBRQ, M_WAITOK); - if (t2p == NULL) - return ENOMEM; error = smb_t2_init(t2p, layer, setup, scred); t2p->t2_flags |= SMBT2_ALLOCED; if (error) { diff --git a/sys/netproto/smb/smb_subr.c b/sys/netproto/smb/smb_subr.c index b54bedf75a..8e546a668d 100644 --- a/sys/netproto/smb/smb_subr.c +++ b/sys/netproto/smb/smb_subr.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/netsmb/smb_subr.c,v 1.1.2.2 2001/09/03 08:55:11 bp Exp $ - * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.29 2007/03/01 01:46:52 corecode Exp $ + * $DragonFly: src/sys/netproto/smb/smb_subr.c,v 1.30 2008/01/06 16:55:53 swildner Exp $ */ #include #include @@ -158,8 +158,6 @@ smb_memdup(const void *umem, int len) if (len > 8 * 1024) return NULL; p = kmalloc(len, M_SMBSTR, M_WAITOK); - if (p == NULL) - return NULL; bcopy(umem, p, len); return p; } diff --git a/sys/opencrypto/cryptodev.c b/sys/opencrypto/cryptodev.c index 17b3c75d18..4c4ee9ea80 100644 --- a/sys/opencrypto/cryptodev.c +++ b/sys/opencrypto/cryptodev.c @@ -1,5 +1,5 @@ /* $FreeBSD: src/sys/opencrypto/cryptodev.c,v 1.4.2.4 2003/06/03 00:09:02 sam Exp $ */ -/* $DragonFly: src/sys/opencrypto/cryptodev.c,v 1.22 2008/01/05 14:02:40 swildner Exp $ */ +/* $DragonFly: src/sys/opencrypto/cryptodev.c,v 1.23 2008/01/06 16:55:53 swildner Exp $ */ /* $OpenBSD: cryptodev.c,v 1.52 2002/06/19 07:22:46 deraadt Exp $ */ /* @@ -532,8 +532,6 @@ cryptodev_key(struct crypt_kop *kop) } krp = (struct cryptkop *)kmalloc(sizeof *krp, M_XDATA, M_WAITOK | M_ZERO); - if (!krp) - return (ENOMEM); krp->krp_op = kop->crk_op; krp->krp_status = kop->crk_status; krp->krp_iparams = kop->crk_iparams; diff --git a/sys/platform/pc32/i386/k6_mem.c b/sys/platform/pc32/i386/k6_mem.c index 03410d01ad..47b7183c38 100644 --- a/sys/platform/pc32/i386/k6_mem.c +++ b/sys/platform/pc32/i386/k6_mem.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/k6_mem.c,v 1.4.2.2 2002/09/16 21:58:41 dwmalone Exp $ - * $DragonFly: src/sys/platform/pc32/i386/k6_mem.c,v 1.9 2008/01/05 14:02:41 swildner Exp $ + * $DragonFly: src/sys/platform/pc32/i386/k6_mem.c,v 1.10 2008/01/06 16:55:53 swildner Exp $ * */ @@ -113,8 +113,6 @@ k6_mrinit(struct mem_range_softc *sc) { sc->mr_ndesc = 2; /* XXX (BFF) For now, we only have one msr for this */ sc->mr_desc = kmalloc(sc->mr_ndesc * sizeof(struct mem_range_desc), M_MEMDESC, M_WAITOK | M_ZERO); - if (sc->mr_desc == NULL) - panic("k6_mrinit: malloc returns NULL"); reg = rdmsr(UWCCR); for (d = 0; d < sc->mr_ndesc; d++) { diff --git a/sys/platform/pc32/i386/sys_machdep.c b/sys/platform/pc32/i386/sys_machdep.c index 6504b0d489..5e649fed22 100644 --- a/sys/platform/pc32/i386/sys_machdep.c +++ b/sys/platform/pc32/i386/sys_machdep.c @@ -32,7 +32,7 @@ * * from: @(#)sys_machdep.c 5.5 (Berkeley) 1/19/91 * $FreeBSD: src/sys/i386/i386/sys_machdep.c,v 1.47.2.3 2002/10/07 17:20:00 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.31 2007/02/03 17:05:58 corecode Exp $ + * $DragonFly: src/sys/platform/pc32/i386/sys_machdep.c,v 1.32 2008/01/06 16:55:53 swildner Exp $ * */ @@ -297,8 +297,6 @@ user_ldt_alloc(struct pcb *pcb, int len) MALLOC(new_ldt, struct pcb_ldt *, sizeof(struct pcb_ldt), M_SUBPROC, M_WAITOK); - if (new_ldt == NULL) - return NULL; new_ldt->ldt_len = len = NEW_MAX_LD(len); new_ldt->ldt_base = (caddr_t)kmem_alloc(&kernel_map, diff --git a/sys/vfs/nfs/bootp_subr.c b/sys/vfs/nfs/bootp_subr.c index c84365bfa7..90e2a8fb65 100644 --- a/sys/vfs/nfs/bootp_subr.c +++ b/sys/vfs/nfs/bootp_subr.c @@ -38,7 +38,7 @@ * nfs/krpc_subr.c * $NetBSD: krpc_subr.c,v 1.10 1995/08/08 20:43:43 gwr Exp $ * $FreeBSD: src/sys/nfs/bootp_subr.c,v 1.20.2.9 2003/04/24 16:51:08 ambrisko Exp $ - * $DragonFly: src/sys/vfs/nfs/bootp_subr.c,v 1.23 2008/01/05 14:02:41 swildner Exp $ + * $DragonFly: src/sys/vfs/nfs/bootp_subr.c,v 1.24 2008/01/06 16:55:53 swildner Exp $ */ #include "opt_bootp.h" @@ -421,9 +421,6 @@ allocifctx(struct bootpc_globalcontext *gctx) struct bootpc_ifcontext *ifctx; ifctx = (struct bootpc_ifcontext *) kmalloc(sizeof(*ifctx), M_TEMP, M_WAITOK); - if (ifctx == NULL) - panic("Failed to allocate bootp interface context structure"); - bzero(ifctx, sizeof(*ifctx)); ifctx->xid = gctx->xid; #ifdef BOOTP_NO_DHCP @@ -1541,8 +1538,6 @@ bootpc_init(void) tsleep(&time_second, 0, "arpkludge", 10); gctx = kmalloc(sizeof(*gctx), M_TEMP, M_WAITOK | M_ZERO); - if (gctx == NULL) - panic("Failed to allocate bootp global context structure"); gctx->xid = ~0xFFFF; gctx->starttime = time_second; diff --git a/sys/vfs/nwfs/nwfs_vfsops.c b/sys/vfs/nwfs/nwfs_vfsops.c index 659312feeb..9344d1cf82 100644 --- a/sys/vfs/nwfs/nwfs_vfsops.c +++ b/sys/vfs/nwfs/nwfs_vfsops.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_vfsops.c,v 1.6.2.6 2001/10/25 19:18:54 dillon Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_vfsops.c,v 1.29 2007/05/13 18:33:58 swildner Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_vfsops.c,v 1.30 2008/01/06 16:55:53 swildner Exp $ */ #include "opt_ncp.h" #ifndef NCP @@ -172,11 +172,6 @@ nwfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred) mp->mnt_stat.f_iosize = conn->buffer_size; /* We must malloc our own mount info */ MALLOC(nmp,struct nwmount *,sizeof(struct nwmount),M_NWFSDATA, M_WAITOK|M_USE_RESERVE|M_ZERO); - if (nmp == NULL) { - nwfs_printf("could not alloc nwmount\n"); - error = ENOMEM; - goto bad; - } mp->mnt_data = (qaddr_t)nmp; nmp->connh = handle; nmp->n_root = NULL; diff --git a/sys/vfs/smbfs/smbfs_smb.c b/sys/vfs/smbfs/smbfs_smb.c index ca082f18aa..0b53adcc96 100644 --- a/sys/vfs/smbfs/smbfs_smb.c +++ b/sys/vfs/smbfs/smbfs_smb.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_smb.c,v 1.1.2.2 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_smb.c,v 1.10 2008/01/05 14:02:41 swildner Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_smb.c,v 1.11 2008/01/06 16:55:53 swildner Exp $ */ #include #include @@ -1034,8 +1034,6 @@ smbfs_findopenLM2(struct smbfs_fctx *ctx, struct smbnode *dnp, const char *wildcard, int wclen, int attr, struct smb_cred *scred) { ctx->f_name = kmalloc(SMB_MAXFNAMELEN, M_SMBFSDATA, M_WAITOK); - if (ctx->f_name == NULL) - return ENOMEM; ctx->f_infolevel = SMB_DIALECT(SSTOVC(ctx->f_ssp)) < SMB_DIALECT_NTLM0_12 ? SMB_INFO_STANDARD : SMB_FIND_FILE_DIRECTORY_INFO; ctx->f_attrmask = attr; @@ -1174,8 +1172,6 @@ smbfs_findopen(struct smbnode *dnp, const char *wildcard, int wclen, int attr, int error; ctx = kmalloc(sizeof(*ctx), M_SMBFSDATA, M_WAITOK | M_ZERO); - if (ctx == NULL) - return ENOMEM; ctx->f_ssp = dnp->n_mount->sm_share; ctx->f_dnp = dnp; ctx->f_flags = SMBFS_RDD_FINDFIRST; diff --git a/sys/vfs/udf/udf_vfsops.c b/sys/vfs/udf/udf_vfsops.c index 5b3711817d..a906cbabac 100644 --- a/sys/vfs/udf/udf_vfsops.c +++ b/sys/vfs/udf/udf_vfsops.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/udf/udf_vfsops.c,v 1.16 2003/11/05 06:56:08 scottl Exp $ - * $DragonFly: src/sys/vfs/udf/udf_vfsops.c,v 1.26 2007/05/09 00:53:36 dillon Exp $ + * $DragonFly: src/sys/vfs/udf/udf_vfsops.c,v 1.27 2008/01/06 16:55:53 swildner Exp $ */ /* udf_vfsops.c */ @@ -654,8 +654,6 @@ udf_find_partmaps(struct udf_mnt *udfmp, struct logvol_desc *lvd) pms = &pmap->pms; udfmp->s_table = kmalloc(pms->st_size, M_UDFMOUNT, M_WAITOK | M_ZERO); - if (udfmp->s_table == NULL) - return(ENOMEM); /* Calculate the number of sectors per packet. */ /* XXX Logical or physical? */ -- 2.41.0