lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1504766031.7546.14.camel@perches.com>
Date:   Wed, 06 Sep 2017 23:33:51 -0700
From:   Joe Perches <joe@...ches.com>
To:     Allen Pais <allen.lkml@...il.com>, linux-kernel@...r.kernel.org
Cc:     x86@...nel.org
Subject: Re: [PATCH 1/1] x86:mm:return -ENOMEM if kzalloc() fails

On Thu, 2017-09-07 at 11:56 +0530, Allen Pais wrote:
>  Currently on failure the value returned from kzalloc() is -1.
> It should return -ENOMEM.
> 

Looks like there are quite a few of these:
(probably several false positives too)

$ git grep -A3 alloc.*GFP|grep -B3 -P "return\s+\-\d+"
arch/powerpc/platforms/cell/spider-pci.c:	dummy_page_va = kmalloc(PAGE_SIZE, GFP_KERNEL);
arch/powerpc/platforms/cell/spider-pci.c-	if (!dummy_page_va) {
arch/powerpc/platforms/cell/spider-pci.c-		pr_err("SPIDERPCI-IOWA:Alloc dummy_page_va failed.\n");
arch/powerpc/platforms/cell/spider-pci.c-		return -1;
--
--
arch/x86/mm/kmmio.c:	f = kzalloc(sizeof(*f), GFP_ATOMIC);
arch/x86/mm/kmmio.c-	if (!f)
arch/x86/mm/kmmio.c-		return -1;
--
drivers/bluetooth/bluecard_cs.c:	skb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);
drivers/bluetooth/bluecard_cs.c-	if (!skb) {
drivers/bluetooth/bluecard_cs.c-		BT_ERR("Can't allocate mem for new packet");
drivers/bluetooth/bluecard_cs.c-		return -1;
--
drivers/crypto/omap-aes-gcm.c:	sk_req = skcipher_request_alloc(ctx->ctr, GFP_KERNEL);
drivers/crypto/omap-aes-gcm.c-	if (!sk_req) {
drivers/crypto/omap-aes-gcm.c-		pr_err("skcipher: Failed to allocate request\n");
drivers/crypto/omap-aes-gcm.c-		return -1;
--
--
drivers/gpu/drm/gma500/mid_bios.c:	gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
drivers/gpu/drm/gma500/mid_bios.c-	if (!gct)
drivers/gpu/drm/gma500/mid_bios.c-		return -1;
--
drivers/hid/usbhid/hiddev.c-	if ((len = usb_string(dev, idx, buf, HID_STRING_SIZE-1)) < 0) {
--
drivers/hid/usbhid/hiddev.c:	if (!(hiddev = kzalloc(sizeof(struct hiddev), GFP_KERNEL)))
drivers/hid/usbhid/hiddev.c-		return -1;
--
drivers/hid/usbhid/hiddev.c-	init_waitqueue_head(&hiddev->wait);
--
drivers/hid/usbhid/usbkbd.c:	if (!(kbd->irq = usb_alloc_urb(0, GFP_KERNEL)))
drivers/hid/usbhid/usbkbd.c-		return -1;
drivers/hid/usbhid/usbkbd.c:	if (!(kbd->led = usb_alloc_urb(0, GFP_KERNEL)))
drivers/hid/usbhid/usbkbd.c-		return -1;
drivers/hid/usbhid/usbkbd.c:	if (!(kbd->new = usb_alloc_coherent(dev, 8, GFP_ATOMIC, &kbd->new_dma)))
drivers/hid/usbhid/usbkbd.c-		return -1;
drivers/hid/usbhid/usbkbd.c:	if (!(kbd->cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL)))
drivers/hid/usbhid/usbkbd.c-		return -1;
drivers/hid/usbhid/usbkbd.c:	if (!(kbd->leds = usb_alloc_coherent(dev, 1, GFP_ATOMIC, &kbd->leds_dma)))
drivers/hid/usbhid/usbkbd.c-		return -1;
--
drivers/isdn/capi/capi.c:	n = kmalloc(sizeof(*n), GFP_ATOMIC);
drivers/isdn/capi/capi.c-	if (unlikely(!n)) {
drivers/isdn/capi/capi.c-		printk(KERN_ERR "capi: alloc datahandle failed\n");
drivers/isdn/capi/capi.c-		return -1;
--
drivers/isdn/capi/capidrv.c:	n = kmalloc(sizeof(struct ncci_datahandle_queue), GFP_ATOMIC);
drivers/isdn/capi/capidrv.c-	if (!n) {
drivers/isdn/capi/capidrv.c-		printk(KERN_ERR "capidrv: kmalloc ncci_datahandle failed\n");
drivers/isdn/capi/capidrv.c-		return -1;
--
drivers/isdn/capi/capidrv.c:	if (!(card = kzalloc(sizeof(capidrv_contr), GFP_ATOMIC))) {
drivers/isdn/capi/capidrv.c-		printk(KERN_WARNING
drivers/isdn/capi/capidrv.c-		       "capidrv: (%s) Could not allocate contr-struct.\n", id);
drivers/isdn/capi/capidrv.c-		return -1;
--
--
drivers/isdn/i4l/isdn_common.c:	if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
drivers/isdn/i4l/isdn_common.c-		printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n");
drivers/isdn/i4l/isdn_common.c-		return -1;
--
--
drivers/media/pci/ivtv/ivtv-udma.c:				dma->bouncemap[map_offset] = alloc_page(GFP_KERNEL);
drivers/media/pci/ivtv/ivtv-udma.c-			if (dma->bouncemap[map_offset] == NULL)
drivers/media/pci/ivtv/ivtv-udma.c-				return -1;
--
drivers/media/rc/ati_remote.c:	ati_remote->inbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
drivers/media/rc/ati_remote.c-					       &ati_remote->inbuf_dma);
drivers/media/rc/ati_remote.c-	if (!ati_remote->inbuf)
drivers/media/rc/ati_remote.c-		return -1;
--
drivers/media/rc/ati_remote.c:	ati_remote->outbuf = usb_alloc_coherent(udev, DATA_BUFSIZE, GFP_ATOMIC,
drivers/media/rc/ati_remote.c-						&ati_remote->outbuf_dma);
drivers/media/rc/ati_remote.c-	if (!ati_remote->outbuf)
drivers/media/rc/ati_remote.c-		return -1;
--
drivers/media/rc/ati_remote.c:	ati_remote->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
drivers/media/rc/ati_remote.c-	if (!ati_remote->irq_urb)
drivers/media/rc/ati_remote.c-		return -1;
drivers/media/rc/ati_remote.c-
drivers/media/rc/ati_remote.c:	ati_remote->out_urb = usb_alloc_urb(0, GFP_KERNEL);
drivers/media/rc/ati_remote.c-	if (!ati_remote->out_urb)
drivers/media/rc/ati_remote.c-		return -1;
--
--
drivers/message/fusion/mptbase.c:		mem = kmalloc(sz, GFP_ATOMIC);
drivers/message/fusion/mptbase.c-		if (mem == NULL)
drivers/message/fusion/mptbase.c-			return -1;
--
--
drivers/message/fusion/mptbase.c:		mem = kmalloc(sz, GFP_ATOMIC);
drivers/message/fusion/mptbase.c-		if (mem == NULL)
drivers/message/fusion/mptbase.c-			return -1;
--
--
drivers/message/fusion/mptbase.c:		mem = kmalloc(sz, GFP_ATOMIC);
drivers/message/fusion/mptbase.c-		if (mem == NULL)
drivers/message/fusion/mptbase.c-			return -1;
--
drivers/mtd/nand/nandsim.c:		mypage->byte = kmem_cache_alloc(ns->nand_pages_slab, GFP_NOFS);
drivers/mtd/nand/nandsim.c-		if (mypage->byte == NULL) {
drivers/mtd/nand/nandsim.c-			NS_ERR("prog_page: error allocating memory for page %d\n", ns->regs.row);
drivers/mtd/nand/nandsim.c-			return -1;
--
--
drivers/net/bonding/bond_alb.c:	new_hashtbl = kmalloc(size, GFP_KERNEL);
drivers/net/bonding/bond_alb.c-	if (!new_hashtbl)
drivers/net/bonding/bond_alb.c-		return -1;
--
drivers/net/ethernet/ibm/ibmveth.c:	pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL);
drivers/net/ethernet/ibm/ibmveth.c-
drivers/net/ethernet/ibm/ibmveth.c-	if (!pool->free_map)
drivers/net/ethernet/ibm/ibmveth.c-		return -1;
--
--
drivers/net/ethernet/ibm/ibmvnic.c:	allqueues = kcalloc(total_queues, sizeof(*allqueues), GFP_KERNEL);
drivers/net/ethernet/ibm/ibmvnic.c-	if (!allqueues)
drivers/net/ethernet/ibm/ibmvnic.c-		return -1;
--
drivers/net/ethernet/sun/cassini.c-		if (page) {
--
drivers/net/ethernet/sun/cassini.c:		if ((page[i] = cas_page_alloc(cp, GFP_KERNEL)) == NULL)
drivers/net/ethernet/sun/cassini.c-			return -1;
--
--
drivers/net/wireless/marvell/mwifiex/sdio.c:		skb = mwifiex_alloc_dma_align_buf(rx_len, GFP_KERNEL);
drivers/net/wireless/marvell/mwifiex/sdio.c-		if (!skb)
drivers/net/wireless/marvell/mwifiex/sdio.c-			return -1;
--
--
drivers/net/wireless/marvell/mwifiex/usb.c:		card->rx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL);
drivers/net/wireless/marvell/mwifiex/usb.c-		if (!card->rx_data_list[i].urb)
drivers/net/wireless/marvell/mwifiex/usb.c-			return -1;
--
drivers/parisc/eisa_enumerator.c-			res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1;
--
drivers/parisc/eisa_enumerator.c:	if (NULL == (board = kmalloc(8, GFP_KERNEL))) {
drivers/parisc/eisa_enumerator.c-		return -1;
--
--
drivers/pnp/pnpbios/core.c:	node = kzalloc(node_info.max_node_size, GFP_KERNEL);
drivers/pnp/pnpbios/core.c-	if (!node)
drivers/pnp/pnpbios/core.c-		return -1;
--
--
drivers/pnp/pnpbios/core.c:	node = kzalloc(node_info.max_node_size, GFP_KERNEL);
drivers/pnp/pnpbios/core.c-	if (!node)
drivers/pnp/pnpbios/core.c-		return -1;
--
drivers/scsi/megaraid/megaraid_mbox.c-		con_log(CL_ANN, (KERN_WARNING
--
drivers/scsi/megaraid/megaraid_mbox.c:	raid_dev = kzalloc(sizeof(mraid_device_t), GFP_KERNEL);
drivers/scsi/megaraid/megaraid_mbox.c-	if (raid_dev == NULL) return -1;
--
--
drivers/staging/rtlwifi/halmac/rtl_halmac.c:		comp = kzalloc(sizeof(*comp), GFP_KERNEL);
drivers/staging/rtlwifi/halmac/rtl_halmac.c-		if (!comp)
drivers/staging/rtlwifi/halmac/rtl_halmac.c-			return -1;
--
--
drivers/staging/rtlwifi/halmac/rtl_halmac.c:	indicator = kzalloc(size, GFP_KERNEL);
drivers/staging/rtlwifi/halmac/rtl_halmac.c-	if (!indicator)
drivers/staging/rtlwifi/halmac/rtl_halmac.c-		return -1;
--
--
drivers/target/iscsi/cxgbit/cxgbit_cm.c:	skb = alloc_skb(len, GFP_KERNEL);
drivers/target/iscsi/cxgbit/cxgbit_cm.c-	if (!skb)
drivers/target/iscsi/cxgbit/cxgbit_cm.c-		return -1;
--
--
drivers/target/iscsi/cxgbit/cxgbit_target.c:		page = alloc_page(GFP_KERNEL | __GFP_ZERO);
drivers/target/iscsi/cxgbit/cxgbit_target.c-		if (!page)
drivers/target/iscsi/cxgbit/cxgbit_target.c-			return -1;
--
--
drivers/target/iscsi/iscsi_target.c:	iscsit_global = kzalloc(sizeof(*iscsit_global), GFP_KERNEL);
drivers/target/iscsi/iscsi_target.c-	if (!iscsit_global)
drivers/target/iscsi/iscsi_target.c-		return -1;
--
drivers/target/iscsi/iscsi_target_nego.c:	tmpbuf = kzalloc(payload_length + 1, GFP_KERNEL);
drivers/target/iscsi/iscsi_target_nego.c-	if (!tmpbuf) {
drivers/target/iscsi/iscsi_target_nego.c-		pr_err("Unable to allocate memory for tmpbuf.\n");
drivers/target/iscsi/iscsi_target_nego.c-		return -1;
--
drivers/target/iscsi/iscsi_target_util.c:	r2t = kmem_cache_zalloc(lio_r2t_cache, GFP_ATOMIC);
drivers/target/iscsi/iscsi_target_util.c-	if (!r2t) {
drivers/target/iscsi/iscsi_target_util.c-		pr_err("Unable to allocate memory for struct iscsi_r2t.\n");
drivers/target/iscsi/iscsi_target_util.c-		return -1;
--
--
drivers/usb/gadget/udc/fsl_udc_core.c:	udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL);
drivers/usb/gadget/udc/fsl_udc_core.c-	if (!udc->eps)
drivers/usb/gadget/udc/fsl_udc_core.c-		return -1;
--
--
drivers/usb/host/ehci-q.c:	qtd = ehci_qtd_alloc(ehci, GFP_KERNEL);
drivers/usb/host/ehci-q.c-	if (unlikely(!qtd))
drivers/usb/host/ehci-q.c-		return -1;
--
--
drivers/usb/serial/io_edgeport.c:	pStringDesc = kmalloc(StringDesc.bLength, GFP_KERNEL);
drivers/usb/serial/io_edgeport.c-	if (!pStringDesc)
drivers/usb/serial/io_edgeport.c-		return -1;
--
drivers/usb/storage/sddr55.c:	buffer = kmalloc( numblocks * 2, GFP_NOIO );
drivers/usb/storage/sddr55.c-	
drivers/usb/storage/sddr55.c-	if (!buffer)
drivers/usb/storage/sddr55.c-		return -1;
--
--
drivers/video/fbdev/matrox/matroxfb_base.c:	minfo = kzalloc(sizeof(*minfo), GFP_KERNEL);
drivers/video/fbdev/matrox/matroxfb_base.c-	if (!minfo)
drivers/video/fbdev/matrox/matroxfb_base.c-		return -1;
--
--
fs/btrfs/check-integrity.c:		block_ctx->pagev[i] = alloc_page(GFP_NOFS);
fs/btrfs/check-integrity.c-		if (!block_ctx->pagev[i])
fs/btrfs/check-integrity.c-			return -1;
--
fs/btrfs/check-integrity.c:	state = kvzalloc(sizeof(*state), GFP_KERNEL);
fs/btrfs/check-integrity.c-	if (!state) {
fs/btrfs/check-integrity.c-		pr_info("btrfs check-integrity: allocation failed!\n");
fs/btrfs/check-integrity.c-		return -1;
--
--
lib/string.c:	p = kmalloc(256 * 2 * 2, GFP_KERNEL);
lib/string.c-	if (!p)
lib/string.c-		return -1;
--
--
lib/string.c:	p = kmalloc(256 * 2 * 4, GFP_KERNEL);
lib/string.c-	if (!p)
lib/string.c-		return -1;
--
--
lib/string.c:	p = kmalloc(256 * 2 * 8, GFP_KERNEL);
lib/string.c-	if (!p)
lib/string.c-		return -1;
--
--
net/atm/lec.c:	skb = alloc_skb(sizeof(struct atmlec_msg), GFP_ATOMIC);
net/atm/lec.c-	if (!skb)
net/atm/lec.c-		return -1;
--
--
net/atm/lec.c:		skb = alloc_skb(*sizeoftlvs, GFP_ATOMIC);
net/atm/lec.c-		if (skb == NULL)
net/atm/lec.c-			return -1;
--
net/ipv4/igmp.c:	skb = alloc_skb(IGMP_SIZE + hlen + tlen, GFP_ATOMIC);
net/ipv4/igmp.c-	if (!skb) {
net/ipv4/igmp.c-		ip_rt_put(rt);
net/ipv4/igmp.c-		return -1;
--
--
net/ipv4/tcp_output.c:	nskb = sk_stream_alloc_skb(sk, probe_size, GFP_ATOMIC, false);
net/ipv4/tcp_output.c-	if (!nskb)
net/ipv4/tcp_output.c-		return -1;
--
net/netrom/af_netrom.c:	dev_nr = kzalloc(nr_ndevs * sizeof(struct net_device *), GFP_KERNEL);
net/netrom/af_netrom.c-	if (dev_nr == NULL) {
net/netrom/af_netrom.c-		printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n");
net/netrom/af_netrom.c-		return -1;
--
--
net/sunrpc/auth_gss/svcauth_gss.c:	xdr_seq = kmalloc(4, GFP_KERNEL);
net/sunrpc/auth_gss/svcauth_gss.c-	if (!xdr_seq)
net/sunrpc/auth_gss/svcauth_gss.c-		return -1;
--
sound/oss/ad1848.c:	portc = kmalloc(sizeof(ad1848_port_info), GFP_KERNEL);
sound/oss/ad1848.c-	if(portc==NULL) {
sound/oss/ad1848.c-		release_region(devc->base, 4);
sound/oss/ad1848.c-		return -1;
--
sound/oss/swarm_cs4297a.c:        dma->descrtab = kzalloc(dma->ringsz * sizeof(serdma_descr_t), GFP_KERNEL);
sound/oss/swarm_cs4297a.c-        if (!dma->descrtab) {
sound/oss/swarm_cs4297a.c-                printk(KERN_ERR "cs4297a: kzalloc descrtab failed\n");
sound/oss/swarm_cs4297a.c-                return -1;
--
sound/oss/swarm_cs4297a.c:	if (!(s = kzalloc(sizeof(struct cs4297a_state), GFP_KERNEL))) {
sound/oss/swarm_cs4297a.c-		CS_DBGOUT(CS_ERROR, 1, printk(KERN_ERR
sound/oss/swarm_cs4297a.c-		      "cs4297a: probe() no memory for state struct.\n"));
sound/oss/swarm_cs4297a.c-		return -1;
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ