FreeBSD Bugzilla – Attachment 207432 Details for
Bug 240545
patch to remove unneeded M_WAITOK return value checks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
remove NULL check and handling of it for M_WAITOK cases
remove-rvcheck-mwaitok.diff (text/plain), 11.46 KB, created by
Andrew Reiter
on 2019-09-12 21:28:35 UTC
(
hide
)
Description:
remove NULL check and handling of it for M_WAITOK cases
Filename:
MIME Type:
Creator:
Andrew Reiter
Created:
2019-09-12 21:28:35 UTC
Size:
11.46 KB
patch
obsolete
>diff -Nur sys.orig/cam/ctl/ctl.c sys/cam/ctl/ctl.c >--- sys.orig/cam/ctl/ctl.c 2018-12-06 20:02:07.000000000 -0400 >+++ sys/cam/ctl/ctl.c 2019-09-12 14:59:40.613222000 -0400 >@@ -2645,12 +2645,6 @@ > } > > entries = malloc(ooa_hdr->alloc_len, M_CTL, M_WAITOK | M_ZERO); >- if (entries == NULL) { >- printf("%s: could not allocate %d bytes for OOA " >- "dump\n", __func__, ooa_hdr->alloc_len); >- retval = ENOMEM; >- break; >- } > > mtx_lock(&softc->ctl_lock); > if ((ooa_hdr->flags & CTL_OOA_FLAG_ALL_LUNS) == 0 && >diff -Nur sys.orig/compat/linuxkpi/common/src/linux_usb.c sys/compat/linuxkpi/common/src/linux_usb.c >--- sys.orig/compat/linuxkpi/common/src/linux_usb.c 2018-12-06 20:01:59.000000000 -0400 >+++ sys/compat/linuxkpi/common/src/linux_usb.c 2019-09-12 15:05:21.941082000 -0400 >@@ -1008,16 +1008,13 @@ > } > > urb = malloc(size, M_USBDEV, M_WAITOK | M_ZERO); >- if (urb) { >- >- cv_init(&urb->cv_wait, "URBWAIT"); >- if (iso_packets == 0xFFFF) { >- urb->setup_packet = (void *)(urb + 1); >- urb->transfer_buffer = (void *)(urb->setup_packet + >- sizeof(struct usb_device_request)); >- } else { >- urb->number_of_packets = iso_packets; >- } >+ cv_init(&urb->cv_wait, "URBWAIT"); >+ if (iso_packets == 0xFFFF) { >+ urb->setup_packet = (void *)(urb + 1); >+ urb->transfer_buffer = (void *)(urb->setup_packet + >+ sizeof(struct usb_device_request)); >+ } else { >+ urb->number_of_packets = iso_packets; > } > return (urb); > } >diff -Nur sys.orig/dev/drm2/i915/intel_overlay.c sys/dev/drm2/i915/intel_overlay.c >--- sys.orig/dev/drm2/i915/intel_overlay.c 2018-12-06 20:02:01.000000000 -0400 >+++ sys/dev/drm2/i915/intel_overlay.c 2019-09-12 15:03:26.461945000 -0400 >@@ -1065,8 +1065,6 @@ > } > > params = malloc(sizeof(struct put_image_params), DRM_I915_GEM, M_WAITOK); >- if (!params) >- return -ENOMEM; > > drmmode_obj = drm_mode_object_find(dev, put_image_rec->crtc_id, > DRM_MODE_OBJECT_CRTC); >diff -Nur sys.orig/dev/drm2/i915/intel_ringbuffer.c sys/dev/drm2/i915/intel_ringbuffer.c >--- sys.orig/dev/drm2/i915/intel_ringbuffer.c 2018-12-06 20:02:01.000000000 -0400 >+++ sys/dev/drm2/i915/intel_ringbuffer.c 2019-09-12 15:03:51.069767000 -0400 >@@ -450,8 +450,6 @@ > return 0; > > pc = malloc(sizeof(*pc), DRM_I915_GEM, M_WAITOK); >- if (!pc) >- return -ENOMEM; > > obj = i915_gem_alloc_object(ring->dev, 4096); > if (obj == NULL) { >diff -Nur sys.orig/dev/hpt27xx/hpt27xx_osm_bsd.c sys/dev/hpt27xx/hpt27xx_osm_bsd.c >--- sys.orig/dev/hpt27xx/hpt27xx_osm_bsd.c 2018-12-06 20:02:05.000000000 -0400 >+++ sys/dev/hpt27xx/hpt27xx_osm_bsd.c 2019-09-12 15:01:50.416124000 -0400 >@@ -1195,10 +1195,6 @@ > > for (i=0; i<os_max_queue_comm; i++) { > POS_CMDEXT ext = (POS_CMDEXT)malloc(sizeof(OS_CMDEXT), M_DEVBUF, M_WAITOK); >- if (!ext) { >- os_printk("Can't alloc cmdext(%d)", i); >- return ; >- } > ext->vbus_ext = vbus_ext; > ext->next = vbus_ext->cmdext_list; > vbus_ext->cmdext_list = ext; >diff -Nur sys.orig/dev/hptnr/hptnr_osm_bsd.c sys/dev/hptnr/hptnr_osm_bsd.c >--- sys.orig/dev/hptnr/hptnr_osm_bsd.c 2018-12-06 20:02:05.000000000 -0400 >+++ sys/dev/hptnr/hptnr_osm_bsd.c 2019-09-12 15:02:07.784725000 -0400 >@@ -1386,10 +1386,6 @@ > > for (i=0; i<os_max_queue_comm; i++) { > POS_CMDEXT ext = (POS_CMDEXT)malloc(sizeof(OS_CMDEXT), M_DEVBUF, M_WAITOK); >- if (!ext) { >- os_printk("Can't alloc cmdext(%d)", i); >- return ; >- } > ext->vbus_ext = vbus_ext; > ext->next = vbus_ext->cmdext_list; > vbus_ext->cmdext_list = ext; >diff -Nur sys.orig/dev/hptrr/hptrr_osm_bsd.c sys/dev/hptrr/hptrr_osm_bsd.c >--- sys.orig/dev/hptrr/hptrr_osm_bsd.c 2018-12-06 20:02:05.000000000 -0400 >+++ sys/dev/hptrr/hptrr_osm_bsd.c 2019-09-12 15:02:38.918399000 -0400 >@@ -1034,10 +1034,6 @@ > > for (i=0; i<os_max_queue_comm; i++) { > POS_CMDEXT ext = (POS_CMDEXT)malloc(sizeof(OS_CMDEXT), M_DEVBUF, M_WAITOK); >- if (!ext) { >- os_printk("Can't alloc cmdext(%d)", i); >- return ; >- } > ext->vbus_ext = vbus_ext; > ext->next = vbus_ext->cmdext_list; > vbus_ext->cmdext_list = ext; >diff -Nur sys.orig/dev/mfi/mfi.c sys/dev/mfi/mfi.c >--- sys.orig/dev/mfi/mfi.c 2018-12-06 20:02:02.000000000 -0400 >+++ sys/dev/mfi/mfi.c 2019-09-12 15:06:05.283979000 -0400 >@@ -3638,11 +3638,9 @@ > mfi_aen_entry = malloc(sizeof(struct mfi_aen), M_MFIBUF, > M_WAITOK); > mtx_lock(&sc->mfi_io_lock); >- if (mfi_aen_entry != NULL) { >- mfi_aen_entry->p = curproc; >- TAILQ_INSERT_TAIL(&sc->mfi_aen_pids, mfi_aen_entry, >- aen_link); >- } >+ mfi_aen_entry->p = curproc; >+ TAILQ_INSERT_TAIL(&sc->mfi_aen_pids, mfi_aen_entry, >+ aen_link); > error = mfi_aen_register(sc, l_aen.laen_seq_num, > l_aen.laen_class_locale); > >diff -Nur sys.orig/dev/sound/usb/uaudio.c sys/dev/sound/usb/uaudio.c >--- sys.orig/dev/sound/usb/uaudio.c 2018-12-06 20:02:00.000000000 -0400 >+++ sys/dev/sound/usb/uaudio.c 2019-09-12 15:10:46.267247000 -0400 >@@ -3096,31 +3096,27 @@ > malloc(sizeof(*p_mc_new), M_USBDEV, M_WAITOK); > int ch; > >- if (p_mc_new != NULL) { >- memcpy(p_mc_new, mc, sizeof(*p_mc_new)); >- p_mc_new->next = sc->sc_mixer_root; >- sc->sc_mixer_root = p_mc_new; >- sc->sc_mixer_count++; >+ memcpy(p_mc_new, mc, sizeof(*p_mc_new)); >+ p_mc_new->next = sc->sc_mixer_root; >+ sc->sc_mixer_root = p_mc_new; >+ sc->sc_mixer_count++; > >- /* set default value for all channels */ >- for (ch = 0; ch < p_mc_new->nchan; ch++) { >- switch (p_mc_new->val_default) { >- case 1: >- /* 50% */ >- p_mc_new->wData[ch] = (p_mc_new->maxval + p_mc_new->minval) / 2; >- break; >- case 2: >- /* 100% */ >- p_mc_new->wData[ch] = p_mc_new->maxval; >- break; >- default: >- /* 0% */ >- p_mc_new->wData[ch] = p_mc_new->minval; >- break; >- } >+ /* set default value for all channels */ >+ for (ch = 0; ch < p_mc_new->nchan; ch++) { >+ switch (p_mc_new->val_default) { >+ case 1: >+ /* 50% */ >+ p_mc_new->wData[ch] = (p_mc_new->maxval + p_mc_new->minval) / 2; >+ break; >+ case 2: >+ /* 100% */ >+ p_mc_new->wData[ch] = p_mc_new->maxval; >+ break; >+ default: >+ /* 0% */ >+ p_mc_new->wData[ch] = p_mc_new->minval; >+ break; > } >- } else { >- DPRINTF("out of memory\n"); > } > } > >diff -Nur sys.orig/dev/twa/tw_osl_freebsd.c sys/dev/twa/tw_osl_freebsd.c >--- sys.orig/dev/twa/tw_osl_freebsd.c 2018-12-06 20:02:06.000000000 -0400 >+++ sys/dev/twa/tw_osl_freebsd.c 2019-09-12 15:09:53.562066000 -0400 >@@ -683,21 +683,9 @@ > tw_osli_req_q_init(sc, TW_OSLI_FREE_Q); > tw_osli_req_q_init(sc, TW_OSLI_BUSY_Q); > >- if ((sc->req_ctx_buf = (struct tw_osli_req_context *) >- malloc((sizeof(struct tw_osli_req_context) * >- TW_OSLI_MAX_NUM_REQUESTS), >- TW_OSLI_MALLOC_CLASS, M_WAITOK)) == NULL) { >- tw_osli_printf(sc, "error = %d", >- TW_CL_SEVERITY_ERROR_STRING, >- TW_CL_MESSAGE_SOURCE_FREEBSD_DRIVER, >- 0x2012, >- "Failed to allocate request packets", >- ENOMEM); >- return(ENOMEM); >- } >- bzero(sc->req_ctx_buf, >- sizeof(struct tw_osli_req_context) * TW_OSLI_MAX_NUM_REQUESTS); >- >+ sc->req_ctx_buf = (struct tw_osli_req_context *) >+ malloc((sizeof(struct tw_osli_req_context) * TW_OSLI_MAX_NUM_REQUESTS), >+ TW_OSLI_MALLOC_CLASS, M_WAITOK | M_ZERO); > for (i = 0; i < TW_OSLI_MAX_NUM_REQUESTS; i++) { > req = &(sc->req_ctx_buf[i]); > req->ctlr = sc; >diff -Nur sys.orig/dev/usb/usb_hub.c sys/dev/usb/usb_hub.c >--- sys.orig/dev/usb/usb_hub.c 2018-12-06 20:02:00.000000000 -0400 >+++ sys/dev/usb/usb_hub.c 2019-09-12 15:11:22.490343000 -0400 >@@ -1371,9 +1371,6 @@ > #if (USB_HAVE_FIXED_PORT == 0) > hub = malloc(sizeof(hub[0]) + (sizeof(hub->ports[0]) * nports), > M_USBDEV, M_WAITOK | M_ZERO); >- >- if (hub == NULL) >- goto error; > #else > hub = &sc->sc_hub; > #endif >diff -Nur sys.orig/fs/ext2fs/ext2_extents.c sys/fs/ext2fs/ext2_extents.c >--- sys.orig/fs/ext2fs/ext2_extents.c 2018-12-06 20:01:50.000000000 -0400 >+++ sys/fs/ext2fs/ext2_extents.c 2019-09-12 14:59:59.874529000 -0400 >@@ -1500,8 +1500,6 @@ > > path = malloc(sizeof(struct ext4_extent_path) * (depth + 1), > M_EXT2EXTENTS, M_WAITOK | M_ZERO); >- if (!path) >- return (ENOMEM); > > path[0].ep_header = ehp; > path[0].ep_depth = depth; >diff -Nur sys.orig/fs/ext2fs/ext2_vnops.c sys/fs/ext2fs/ext2_vnops.c >--- sys.orig/fs/ext2fs/ext2_vnops.c 2018-12-06 20:01:50.000000000 -0400 >+++ sys/fs/ext2fs/ext2_vnops.c 2019-09-12 15:01:15.217634000 -0400 >@@ -1063,10 +1063,6 @@ > ext2_dec_nlink(dp); > dp->i_flag |= IN_CHANGE; > dirbuf = malloc(dp->i_e2fs->e2fs_bsize, M_TEMP, M_WAITOK | M_ZERO); >- if (!dirbuf) { >- error = ENOMEM; >- goto bad; >- } > error = vn_rdwr(UIO_READ, fvp, (caddr_t)dirbuf, > ip->i_e2fs->e2fs_bsize, (off_t)0, > UIO_SYSSPACE, IO_NODELOCKED | IO_NOMACCHECK, >diff -Nur sys.orig/net/if_vlan.c sys/net/if_vlan.c >--- sys.orig/net/if_vlan.c 2018-12-06 20:01:57.000000000 -0400 >+++ sys/net/if_vlan.c 2019-09-12 15:03:09.495241000 -0400 >@@ -443,11 +443,6 @@ > return; > > hash2 = malloc(sizeof(struct ifvlanhead) * n2, M_VLAN, M_WAITOK); >- if (hash2 == NULL) { >- printf("%s: out of memory -- hash size not changed\n", >- __func__); >- return; /* We can live with the old hash table */ >- } > for (j = 0; j < n2; j++) > CK_SLIST_INIT(&hash2[j]); > for (i = 0; i < n; i++) >diff -Nur sys.orig/netinet/ip_divert.c sys/netinet/ip_divert.c >--- sys.orig/netinet/ip_divert.c 2018-12-06 20:01:56.000000000 -0400 >+++ sys/netinet/ip_divert.c 2019-09-12 15:04:14.941913000 -0400 >@@ -674,8 +674,6 @@ > return error; > > inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK); >- if (inp_list == NULL) >- return ENOMEM; > > INP_INFO_RLOCK_ET(&V_divcbinfo, et); > for (inp = CK_LIST_FIRST(V_divcbinfo.ipi_listhead), i = 0; inp && i < n; >diff -Nur sys.orig/netinet/sctp_usrreq.c sys/netinet/sctp_usrreq.c >--- sys.orig/netinet/sctp_usrreq.c 2018-12-06 20:01:56.000000000 -0400 >+++ sys/netinet/sctp_usrreq.c 2019-09-12 15:08:01.142750000 -0400 >@@ -7312,8 +7312,6 @@ > * Do the malloc first in case it blocks. > */ > SCTP_MALLOC_SONAME(sin, struct sockaddr_in *, sizeof *sin); >- if (sin == NULL) >- return (ENOMEM); > sin->sin_family = AF_INET; > sin->sin_len = sizeof(*sin); > inp = (struct sctp_inpcb *)so->so_pcb; >diff -Nur sys.orig/netinet/udp_usrreq.c sys/netinet/udp_usrreq.c >--- sys.orig/netinet/udp_usrreq.c 2018-12-06 20:01:56.000000000 -0400 >+++ sys/netinet/udp_usrreq.c 2019-09-12 15:11:03.106911000 -0400 >@@ -897,8 +897,6 @@ > return (error); > > inp_list = malloc(n * sizeof *inp_list, M_TEMP, M_WAITOK); >- if (inp_list == NULL) >- return (ENOMEM); > > INP_INFO_RLOCK_ET(&V_udbinfo, et); > for (inp = CK_LIST_FIRST(V_udbinfo.ipi_listhead), i = 0; inp && i < n; >diff -Nur sys.orig/netpfil/ipfw/ip_dummynet.c sys/netpfil/ipfw/ip_dummynet.c >--- sys.orig/netpfil/ipfw/ip_dummynet.c 2018-12-06 20:02:10.000000000 -0400 >+++ sys/netpfil/ipfw/ip_dummynet.c 2019-09-12 15:04:48.541958000 -0400 >@@ -1348,10 +1348,6 @@ > return err; > } > ep = malloc(l, M_DUMMYNET, M_WAITOK); >- if(!ep) { >- err = ENOMEM ; >- return err; >- } > do { > err = sooptcopyin(sopt, ep, l, l); > if(err) >@@ -1403,10 +1399,6 @@ > return err; > } > ep = malloc(l, M_DUMMYNET, M_WAITOK); >- if(!ep) { >- err = ENOMEM ; >- return err; >- } > do { > err = sooptcopyin(sopt, ep, l, l); > if(err) >diff -Nur sys.orig/netsmb/smb_rq.c sys/netsmb/smb_rq.c >--- sys.orig/netsmb/smb_rq.c 2018-12-06 20:02:11.000000000 -0400 >+++ sys/netsmb/smb_rq.c 2019-09-12 15:08:28.964219000 -0400 >@@ -67,8 +67,6 @@ > int error; > > rqp = malloc(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) { >@@ -380,8 +378,6 @@ > int error; > > t2p = malloc(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) {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 240545
: 207432 |
208142
|
208157
|
208169
|
208185