Commit 78110bb8 authored by Joe Perches's avatar Joe Perches Committed by Greg Kroah-Hartman
Browse files

staging: Remove unnecessary OOM messages



alloc failures already get standardized OOM
messages and a dump_stack.

For the affected mallocs around these OOM messages:

Converted kzallocs with multiplies to kcalloc.
Converted kmallocs with multiplies to kmalloc_array.
Converted a kmalloc/strlen/strncpy to kstrdup.
Moved a spin_lock below a removed OOM message and
removed a now unnecessary spin_unlock.
Neatened alignment and whitespace.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ad463ac4
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -164,11 +164,8 @@ static void enable_oled(struct asus_oled_dev *odev, uint8_t enabl)
	struct asus_oled_packet *packet;

	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);

	if (!packet) {
		dev_err(&odev->udev->dev, "out of memory\n");
	if (!packet)
		return;
	}

	setup_packet_header(packet, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00);

@@ -323,11 +320,8 @@ static void send_data(struct asus_oled_dev *odev)
	struct asus_oled_packet *packet;

	packet = kzalloc(sizeof(struct asus_oled_packet), GFP_KERNEL);

	if (!packet) {
		dev_err(&odev->udev->dev, "out of memory\n");
	if (!packet)
		return;
	}

	if (odev->pack_mode == PACK_MODE_G1) {
		/* When sending roll-mode data the display updated only
@@ -665,11 +659,8 @@ static int asus_oled_probe(struct usb_interface *interface,
	}

	odev = kzalloc(sizeof(struct asus_oled_dev), GFP_KERNEL);

	if (odev == NULL) {
		dev_err(&interface->dev, "Out of memory\n");
	if (odev == NULL)
		return -ENOMEM;
	}

	odev->udev = usb_get_dev(udev);
	odev->pic_mode = ASUS_OLED_STATIC;
+4 −10
Original line number Diff line number Diff line
@@ -190,9 +190,9 @@ static int usbbcm_device_probe(struct usb_interface *intf, const struct usb_devi
	}

	/* Allocate interface adapter structure */
	psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter), GFP_KERNEL);
	psIntfAdapter = kzalloc(sizeof(struct bcm_interface_adapter),
				GFP_KERNEL);
	if (psIntfAdapter == NULL) {
		dev_err(&udev->dev, DRV_NAME ": no memory for Interface adapter\n");
		AdapterFree(psAdapter);
		return -ENOMEM;
	}
@@ -564,12 +564,9 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
			psIntfAdapter->sIntrIn.int_in_interval = endpoint->bInterval;
			psIntfAdapter->sIntrIn.int_in_buffer =
						kmalloc(buffer_size, GFP_KERNEL);
			if (!psIntfAdapter->sIntrIn.int_in_buffer) {
				dev_err(&psIntfAdapter->udev->dev,
					"could not allocate interrupt_in_buffer\n");
			if (!psIntfAdapter->sIntrIn.int_in_buffer)
				return -EINVAL;
		}
		}

		if (!psIntfAdapter->sIntrOut.int_out_endpointAddr && bcm_usb_endpoint_is_int_out(endpoint)) {
			if (!psIntfAdapter->sBulkOut.bulk_out_endpointAddr &&
@@ -587,14 +584,11 @@ static int InterfaceAdapterInit(struct bcm_interface_adapter *psIntfAdapter)
				psIntfAdapter->sIntrOut.int_out_endpointAddr = endpoint->bEndpointAddress;
				psIntfAdapter->sIntrOut.int_out_interval = endpoint->bInterval;
				psIntfAdapter->sIntrOut.int_out_buffer = kmalloc(buffer_size, GFP_KERNEL);
				if (!psIntfAdapter->sIntrOut.int_out_buffer) {
					dev_err(&psIntfAdapter->udev->dev,
						"could not allocate interrupt_out_buffer\n");
				if (!psIntfAdapter->sIntrOut.int_out_buffer)
					return -EINVAL;
			}
		}
	}
	}

	usb_set_intfdata(psIntfAdapter->interface, psIntfAdapter);

+1 −3
Original line number Diff line number Diff line
@@ -1391,10 +1391,8 @@ static int ced_probe(struct usb_interface *interface,

	// allocate memory for our device extension and initialize it
	pdx = kzalloc(sizeof(*pdx), GFP_KERNEL);
	if (!pdx) {
		dev_err(&interface->dev, "Out of memory\n");
	if (!pdx)
		goto error;
	}

	for (i = 0; i < MAX_TRANSAREAS; ++i)	// Initialise the wait queues
	{
+2 −3
Original line number Diff line number Diff line
@@ -203,10 +203,9 @@ static int __comedi_device_postconfig_async(struct comedi_device *dev,
	}

	async = kzalloc(sizeof(*async), GFP_KERNEL);
	if (!async) {
		dev_warn(dev->class_dev, "failed to allocate async struct\n");
	if (!async)
		return -ENOMEM;
	}

	init_waitqueue_head(&async->wait_head);
	async->subdevice = s;
	s->async = async;
+3 −6
Original line number Diff line number Diff line
@@ -1105,10 +1105,9 @@ dio200_subdev_intr_init(struct comedi_device *dev, struct comedi_subdevice *s,
	struct dio200_subdev_intr *subpriv;

	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
	if (!subpriv) {
		dev_err(dev->class_dev, "error! out of memory!\n");
	if (!subpriv)
		return -ENOMEM;
	}

	subpriv->ofs = offset;
	subpriv->valid_isns = valid_isns;
	spin_lock_init(&subpriv->spinlock);
@@ -1444,10 +1443,8 @@ dio200_subdev_8254_init(struct comedi_device *dev, struct comedi_subdevice *s,
	unsigned int chan;

	subpriv = kzalloc(sizeof(*subpriv), GFP_KERNEL);
	if (!subpriv) {
		dev_err(dev->class_dev, "error! out of memory!\n");
	if (!subpriv)
		return -ENOMEM;
	}

	s->private = subpriv;
	s->type = COMEDI_SUBD_COUNTER;
Loading