Commit c38e8657 authored by Markus Elfring's avatar Markus Elfring Committed by Mauro Carvalho Chehab

media: drivers: delete error messages for failed memory allocation

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

[mchehab@s-opensource.com: fold several similar patches into one]
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarHans Verkuil <hansverk@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent a0ec8d1d
...@@ -75,10 +75,8 @@ int cypress_load_firmware(struct usb_device *udev, ...@@ -75,10 +75,8 @@ int cypress_load_firmware(struct usb_device *udev,
int ret, pos = 0; int ret, pos = 0;
hx = kmalloc(sizeof(struct hexline), GFP_KERNEL); hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
if (!hx) { if (!hx)
dev_err(&udev->dev, "%s: kmalloc() failed\n", KBUILD_MODNAME);
return -ENOMEM; return -ENOMEM;
}
/* stop the CPU */ /* stop the CPU */
hx->data[0] = 1; hx->data[0] = 1;
......
...@@ -1301,10 +1301,8 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode) ...@@ -1301,10 +1301,8 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
buffer = kmalloc(sizeof(struct sms_msg_data) + buffer = kmalloc(sizeof(struct sms_msg_data) +
SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA); SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
if (!buffer) { if (!buffer)
pr_err("Could not allocate buffer for init device message.\n");
return -ENOMEM; return -ENOMEM;
}
msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer); msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ, SMS_INIT_MSG(&msg->x_msg_header, MSG_SMS_INIT_DEVICE_REQ,
...@@ -1687,10 +1685,9 @@ static int smscore_validate_client(struct smscore_device_t *coredev, ...@@ -1687,10 +1685,9 @@ static int smscore_validate_client(struct smscore_device_t *coredev,
return -EEXIST; return -EEXIST;
} }
listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL); listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
if (!listentry) { if (!listentry)
pr_err("Can't allocate memory for client id.\n");
return -ENOMEM; return -ENOMEM;
}
listentry->id = id; listentry->id = id;
listentry->data_type = data_type; listentry->data_type = data_type;
list_add_locked(&listentry->entry, &client->idlist, list_add_locked(&listentry->entry, &client->idlist,
...@@ -1725,10 +1722,8 @@ int smscore_register_client(struct smscore_device_t *coredev, ...@@ -1725,10 +1722,8 @@ int smscore_register_client(struct smscore_device_t *coredev,
} }
newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL); newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
if (!newclient) { if (!newclient)
pr_err("Failed to allocate memory for client.\n");
return -ENOMEM; return -ENOMEM;
}
INIT_LIST_HEAD(&newclient->idlist); INIT_LIST_HEAD(&newclient->idlist);
newclient->coredev = coredev; newclient->coredev = coredev;
......
...@@ -456,10 +456,9 @@ struct dvb_frontend *as102_attach(const char *name, ...@@ -456,10 +456,9 @@ struct dvb_frontend *as102_attach(const char *name,
struct dvb_frontend *fe; struct dvb_frontend *fe;
state = kzalloc(sizeof(struct as102_state), GFP_KERNEL); state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
if (state == NULL) { if (!state)
pr_err("%s: unable to allocate memory for state\n", __func__);
return NULL; return NULL;
}
fe = &state->frontend; fe = &state->frontend;
fe->demodulator_priv = state; fe->demodulator_priv = state;
state->ops = ops; state->ops = ops;
......
...@@ -555,10 +555,9 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe, ...@@ -555,10 +555,9 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
struct cx24113_state *state = struct cx24113_state *state =
kzalloc(sizeof(struct cx24113_state), GFP_KERNEL); kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
int rc; int rc;
if (state == NULL) {
cx_err("Unable to kzalloc\n"); if (!state)
goto error; goto error;
}
/* setup the state */ /* setup the state */
state->config = config; state->config = config;
......
...@@ -227,7 +227,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg, ...@@ -227,7 +227,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
buf = kmalloc(len + 1, GFP_KERNEL); buf = kmalloc(len + 1, GFP_KERNEL);
if (buf == NULL) { if (buf == NULL) {
printk("Unable to kmalloc\n");
ret = -ENOMEM; ret = -ENOMEM;
goto error; goto error;
} }
......
...@@ -911,7 +911,6 @@ static int load_firmware(struct drxd_state *state, const char *fw_name) ...@@ -911,7 +911,6 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL); state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
if (state->microcode == NULL) { if (state->microcode == NULL) {
release_firmware(fw); release_firmware(fw);
printk(KERN_ERR "drxd: firmware load failure: no memory\n");
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -277,10 +277,8 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg, ...@@ -277,10 +277,8 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg,
u8 *buf; u8 *buf;
buf = kmalloc(33, GFP_KERNEL); buf = kmalloc(33, GFP_KERNEL);
if (buf == NULL) { if (!buf)
printk(KERN_ERR "Unable to kmalloc\n");
return -ENOMEM; return -ENOMEM;
}
*(buf) = reg; *(buf) = reg;
...@@ -842,10 +840,8 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config, ...@@ -842,10 +840,8 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL); state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL);
if (state == NULL) { if (!state)
printk(KERN_ERR "Unable to kmalloc\n");
goto error2; goto error2;
}
state->config = config; state->config = config;
state->i2c = i2c; state->i2c = i2c;
......
...@@ -2072,11 +2072,8 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, ...@@ -2072,11 +2072,8 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL); state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL);
if (state == NULL) { if (!state)
dev_err(&i2c->dev,
"%s: unable to allocate memory for state\n", __func__);
goto error; goto error;
}
/* setup the state */ /* setup the state */
state->config = config; state->config = config;
......
...@@ -696,7 +696,6 @@ static int si2168_probe(struct i2c_client *client, ...@@ -696,7 +696,6 @@ static int si2168_probe(struct i2c_client *client,
dev = kzalloc(sizeof(*dev), GFP_KERNEL); dev = kzalloc(sizeof(*dev), GFP_KERNEL);
if (!dev) { if (!dev) {
ret = -ENOMEM; ret = -ENOMEM;
dev_err(&client->dev, "kzalloc() failed\n");
goto err; goto err;
} }
......
...@@ -384,7 +384,6 @@ static int sp2_probe(struct i2c_client *client, ...@@ -384,7 +384,6 @@ static int sp2_probe(struct i2c_client *client,
s = kzalloc(sizeof(struct sp2), GFP_KERNEL); s = kzalloc(sizeof(struct sp2), GFP_KERNEL);
if (!s) { if (!s) {
ret = -ENOMEM; ret = -ENOMEM;
dev_err(&client->dev, "kzalloc() failed\n");
goto err; goto err;
} }
......
...@@ -3316,10 +3316,8 @@ static int adv76xx_probe(struct i2c_client *client, ...@@ -3316,10 +3316,8 @@ static int adv76xx_probe(struct i2c_client *client,
client->addr << 1); client->addr << 1);
state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL); state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
if (!state) { if (!state)
v4l_err(client, "Could not allocate adv76xx_state memory!\n");
return -ENOMEM; return -ENOMEM;
}
state->i2c_clients[ADV76XX_PAGE_IO] = client; state->i2c_clients[ADV76XX_PAGE_IO] = client;
......
...@@ -3468,10 +3468,8 @@ static int adv7842_probe(struct i2c_client *client, ...@@ -3468,10 +3468,8 @@ static int adv7842_probe(struct i2c_client *client,
} }
state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL); state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL);
if (!state) { if (!state)
v4l_err(client, "Could not allocate adv7842_state memory!\n");
return -ENOMEM; return -ENOMEM;
}
/* platform data */ /* platform data */
state->pdata = *pdata; state->pdata = *pdata;
......
...@@ -910,11 +910,9 @@ static int cx18_probe(struct pci_dev *pci_dev, ...@@ -910,11 +910,9 @@ static int cx18_probe(struct pci_dev *pci_dev,
} }
cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC); cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC);
if (cx == NULL) { if (!cx)
printk(KERN_ERR "cx18: cannot manage card %d, out of memory\n",
i);
return -ENOMEM; return -ENOMEM;
}
cx->pci_dev = pci_dev; cx->pci_dev = pci_dev;
cx->instance = i; cx->instance = i;
......
...@@ -165,7 +165,6 @@ static int hopper_pci_probe(struct pci_dev *pdev, ...@@ -165,7 +165,6 @@ static int hopper_pci_probe(struct pci_dev *pdev,
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
if (mantis == NULL) { if (mantis == NULL) {
printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
err = -ENOMEM; err = -ENOMEM;
goto fail0; goto fail0;
} }
......
...@@ -174,10 +174,8 @@ static int mantis_pci_probe(struct pci_dev *pdev, ...@@ -174,10 +174,8 @@ static int mantis_pci_probe(struct pci_dev *pdev,
int err = 0; int err = 0;
mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL); mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
if (mantis == NULL) { if (!mantis)
printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
return -ENOMEM; return -ENOMEM;
}
drvdata = (void *)pci_id->driver_data; drvdata = (void *)pci_id->driver_data;
mantis->num = devs; mantis->num = devs;
......
...@@ -1626,23 +1626,18 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) ...@@ -1626,23 +1626,18 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
meye.mchip_dev = pcidev; meye.mchip_dev = pcidev;
meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
if (!meye.grab_temp) { if (!meye.grab_temp)
v4l2_err(v4l2_dev, "grab buffer allocation failed\n");
goto outvmalloc; goto outvmalloc;
}
spin_lock_init(&meye.grabq_lock); spin_lock_init(&meye.grabq_lock);
if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS, if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
GFP_KERNEL)) { GFP_KERNEL))
v4l2_err(v4l2_dev, "fifo allocation failed\n");
goto outkfifoalloc1; goto outkfifoalloc1;
}
spin_lock_init(&meye.doneq_lock); spin_lock_init(&meye.doneq_lock);
if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS, if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
GFP_KERNEL)) { GFP_KERNEL))
v4l2_err(v4l2_dev, "fifo allocation failed\n");
goto outkfifoalloc2; goto outkfifoalloc2;
}
meye.vdev = meye_template; meye.vdev = meye_template;
meye.vdev.v4l2_dev = &meye.v4l2_dev; meye.vdev.v4l2_dev = &meye.v4l2_dev;
......
...@@ -261,10 +261,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ...@@ -261,10 +261,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
DEB_EE("\n"); DEB_EE("\n");
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
if (NULL == hexium) { if (!hexium)
pr_err("not enough kernel memory in hexium_attach()\n");
return -ENOMEM; return -ENOMEM;
}
dev->ext_priv = hexium; dev->ext_priv = hexium;
/* enable i2c-port pins */ /* enable i2c-port pins */
......
...@@ -220,10 +220,8 @@ static int hexium_probe(struct saa7146_dev *dev) ...@@ -220,10 +220,8 @@ static int hexium_probe(struct saa7146_dev *dev)
} }
hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL); hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
if (NULL == hexium) { if (!hexium)
pr_err("hexium_probe: not enough kernel memory\n");
return -ENOMEM; return -ENOMEM;
}
/* enable i2c-port pins */ /* enable i2c-port pins */
saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26)); saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
......
...@@ -99,10 +99,8 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port, ...@@ -99,10 +99,8 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
} }
buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL); buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL);
if (!buf) { if (!buf)
log_warn("%s() SAA_ERR_NO_RESOURCES\n", __func__);
goto ret; goto ret;
}
buf->idx = -1; buf->idx = -1;
buf->port = port; buf->port = port;
......
...@@ -1507,10 +1507,8 @@ static int isc_formats_init(struct isc_device *isc) ...@@ -1507,10 +1507,8 @@ static int isc_formats_init(struct isc_device *isc)
isc->user_formats = devm_kcalloc(isc->dev, isc->user_formats = devm_kcalloc(isc->dev,
num_fmts, sizeof(struct isc_format *), num_fmts, sizeof(struct isc_format *),
GFP_KERNEL); GFP_KERNEL);
if (!isc->user_formats) { if (!isc->user_formats)
v4l2_err(&isc->v4l2_dev, "could not allocate memory\n");
return -ENOMEM; return -ENOMEM;
}
fmt = &isc_formats[0]; fmt = &isc_formats[0];
for (i = 0, j = 0; i < ARRAY_SIZE(isc_formats); i++) { for (i = 0, j = 0; i < ARRAY_SIZE(isc_formats); i++) {
......
...@@ -1038,10 +1038,8 @@ static int isi_formats_init(struct atmel_isi *isi) ...@@ -1038,10 +1038,8 @@ static int isi_formats_init(struct atmel_isi *isi)
isi->user_formats = devm_kcalloc(isi->dev, isi->user_formats = devm_kcalloc(isi->dev,
num_fmts, sizeof(struct isi_format *), num_fmts, sizeof(struct isi_format *),
GFP_KERNEL); GFP_KERNEL);
if (!isi->user_formats) { if (!isi->user_formats)
dev_err(isi->dev, "could not allocate memory\n");
return -ENOMEM; return -ENOMEM;
}
memcpy(isi->user_formats, isi_fmts, memcpy(isi->user_formats, isi_fmts,
num_fmts * sizeof(struct isi_format *)); num_fmts * sizeof(struct isi_format *));
...@@ -1176,10 +1174,8 @@ static int atmel_isi_probe(struct platform_device *pdev) ...@@ -1176,10 +1174,8 @@ static int atmel_isi_probe(struct platform_device *pdev)
int ret, i; int ret, i;
isi = devm_kzalloc(&pdev->dev, sizeof(struct atmel_isi), GFP_KERNEL); isi = devm_kzalloc(&pdev->dev, sizeof(struct atmel_isi), GFP_KERNEL);
if (!isi) { if (!isi)
dev_err(&pdev->dev, "Can't allocate interface!\n");
return -ENOMEM; return -ENOMEM;
}
isi->pclk = devm_clk_get(&pdev->dev, "isi_clk"); isi->pclk = devm_clk_get(&pdev->dev, "isi_clk");
if (IS_ERR(isi->pclk)) if (IS_ERR(isi->pclk))
......
...@@ -338,7 +338,6 @@ struct ppi_if *ppi_create_instance(struct platform_device *pdev, ...@@ -338,7 +338,6 @@ struct ppi_if *ppi_create_instance(struct platform_device *pdev,
ppi = kzalloc(sizeof(*ppi), GFP_KERNEL); ppi = kzalloc(sizeof(*ppi), GFP_KERNEL);
if (!ppi) { if (!ppi) {
peripheral_free_list(info->pin_req); peripheral_free_list(info->pin_req);
dev_err(&pdev->dev, "unable to allocate memory for ppi handle\n");
return NULL; return NULL;
} }
ppi->ops = &ppi_ops; ppi->ops = &ppi_ops;
......
...@@ -209,10 +209,8 @@ static int send_control_msg(struct usb_device *udev, u8 request, u16 value, ...@@ -209,10 +209,8 @@ static int send_control_msg(struct usb_device *udev, u8 request, u16 value,
int status; int status;
unsigned char *transfer_buffer = kmalloc(size, GFP_KERNEL); unsigned char *transfer_buffer = kmalloc(size, GFP_KERNEL);
if (!transfer_buffer) { if (!transfer_buffer)
dev_err(&udev->dev, "kmalloc(%d) failed\n", size);
return -ENOMEM; return -ENOMEM;
}
memcpy(transfer_buffer, cp, size); memcpy(transfer_buffer, cp, size);
...@@ -1424,10 +1422,8 @@ static int zr364xx_probe(struct usb_interface *intf, ...@@ -1424,10 +1422,8 @@ static int zr364xx_probe(struct usb_interface *intf,
le16_to_cpu(udev->descriptor.idProduct)); le16_to_cpu(udev->descriptor.idProduct));
cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL); cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL);
if (cam == NULL) { if (!cam)
dev_err(&udev->dev, "cam: out of memory !\n");
return -ENOMEM; return -ENOMEM;
}
cam->v4l2_dev.release = zr364xx_release; cam->v4l2_dev.release = zr364xx_release;
err = v4l2_device_register(&intf->dev, &cam->v4l2_dev); err = v4l2_device_register(&intf->dev, &cam->v4l2_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment