]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
media: drivers: delete error messages for failed memory allocation
authorMarkus Elfring <elfring@users.sourceforge.net>
Mon, 28 Aug 2017 09:46:57 +0000 (05:46 -0400)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Sat, 23 Sep 2017 12:19:55 +0000 (08:19 -0400)
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: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Hans Verkuil <hansverk@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
23 files changed:
drivers/media/common/cypress_firmware.c
drivers/media/common/siano/smscoreapi.c
drivers/media/dvb-frontends/as102_fe.c
drivers/media/dvb-frontends/cx24113.c
drivers/media/dvb-frontends/cx24116.c
drivers/media/dvb-frontends/drxd_hard.c
drivers/media/dvb-frontends/ds3000.c
drivers/media/dvb-frontends/mb86a20s.c
drivers/media/dvb-frontends/si2168.c
drivers/media/dvb-frontends/sp2.c
drivers/media/i2c/adv7604.c
drivers/media/i2c/adv7842.c
drivers/media/pci/cx18/cx18-driver.c
drivers/media/pci/mantis/hopper_cards.c
drivers/media/pci/mantis/mantis_cards.c
drivers/media/pci/meye/meye.c
drivers/media/pci/saa7146/hexium_gemini.c
drivers/media/pci/saa7146/hexium_orion.c
drivers/media/pci/saa7164/saa7164-buffer.c
drivers/media/platform/atmel/atmel-isc.c
drivers/media/platform/atmel/atmel-isi.c
drivers/media/platform/blackfin/ppi.c
drivers/media/usb/zr364xx/zr364xx.c

index 50e3f76d4847412e1280e14c1fe0b44847c8fd57..bfe47bc5f71672e36e379c0df7eb68f7c6de42b9 100644 (file)
@@ -75,10 +75,8 @@ int cypress_load_firmware(struct usb_device *udev,
        int ret, pos = 0;
 
        hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
-       if (!hx) {
-               dev_err(&udev->dev, "%s: kmalloc() failed\n", KBUILD_MODNAME);
+       if (!hx)
                return -ENOMEM;
-       }
 
        /* stop the CPU */
        hx->data[0] = 1;
index e7a0d7798d5b249197b9e21cd0ae6f2066162d20..889b486fbc721feac943e48f0b0a1218e70f3ba0 100644 (file)
@@ -1301,10 +1301,8 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
 
        buffer = kmalloc(sizeof(struct sms_msg_data) +
                        SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
-       if (!buffer) {
-               pr_err("Could not allocate buffer for init device message.\n");
+       if (!buffer)
                return -ENOMEM;
-       }
 
        msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
        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,
                return -EEXIST;
        }
        listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
-       if (!listentry) {
-               pr_err("Can't allocate memory for client id.\n");
+       if (!listentry)
                return -ENOMEM;
-       }
+
        listentry->id = id;
        listentry->data_type = data_type;
        list_add_locked(&listentry->entry, &client->idlist,
@@ -1725,10 +1722,8 @@ int smscore_register_client(struct smscore_device_t *coredev,
        }
 
        newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
-       if (!newclient) {
-               pr_err("Failed to allocate memory for client.\n");
+       if (!newclient)
                return -ENOMEM;
-       }
 
        INIT_LIST_HEAD(&newclient->idlist);
        newclient->coredev = coredev;
index 98d575f2744c6eec7ea11acd37c0b54a623e5fc7..1fb4ab21d78670dfcb9a8a54738baa838f9b3cf0 100644 (file)
@@ -456,10 +456,9 @@ struct dvb_frontend *as102_attach(const char *name,
        struct dvb_frontend *fe;
 
        state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
-       if (state == NULL) {
-               pr_err("%s: unable to allocate memory for state\n", __func__);
+       if (!state)
                return NULL;
-       }
+
        fe = &state->frontend;
        fe->demodulator_priv = state;
        state->ops = ops;
index 0118c2658cf780d4431032e6dd6bd0c510b93b5c..8fc7333c76b70c532118367ac0204c44df5bf77b 100644 (file)
@@ -555,10 +555,9 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
        struct cx24113_state *state =
                kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
        int rc;
-       if (state == NULL) {
-               cx_err("Unable to kzalloc\n");
+
+       if (!state)
                goto error;
-       }
 
        /* setup the state */
        state->config = config;
index e105532bfba848bb098610fc0545d305078a48d9..96af4ffba0f9ee973fd00e596ad9658a8f1d0840 100644 (file)
@@ -227,7 +227,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
 
        buf = kmalloc(len + 1, GFP_KERNEL);
        if (buf == NULL) {
-               printk("Unable to kmalloc\n");
                ret = -ENOMEM;
                goto error;
        }
index 7d04400b18ddf0d5874ec769a4ecafc34df5bae7..47b0d37e70bad38f3ba9f688d53a6b7e0460bf1c 100644 (file)
@@ -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);
        if (state->microcode == NULL) {
                release_firmware(fw);
-               printk(KERN_ERR "drxd: firmware load failure: no memory\n");
                return -ENOMEM;
        }
 
index 0b17a45c56407926818368ee76f2e62192c79470..c2959a9695a71fa84a6f9972893296b3776aaaa0 100644 (file)
@@ -277,10 +277,8 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg,
        u8 *buf;
 
        buf = kmalloc(33, GFP_KERNEL);
-       if (buf == NULL) {
-               printk(KERN_ERR "Unable to kmalloc\n");
+       if (!buf)
                return -ENOMEM;
-       }
 
        *(buf) = reg;
 
@@ -842,10 +840,8 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
 
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL);
-       if (state == NULL) {
-               printk(KERN_ERR "Unable to kmalloc\n");
+       if (!state)
                goto error2;
-       }
 
        state->config = config;
        state->i2c = i2c;
index e8ac8c3e2ec08f26cb10cae5bbb2b8d85345de5c..340984100aecb9989db2b7566bb50840b05cf6ef 100644 (file)
@@ -2072,11 +2072,8 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
 
        /* allocate memory for the internal state */
        state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL);
-       if (state == NULL) {
-               dev_err(&i2c->dev,
-                       "%s: unable to allocate memory for state\n", __func__);
+       if (!state)
                goto error;
-       }
 
        /* setup the state */
        state->config = config;
index 172fc367ccaaccdedadba19f9343e48e364ef06a..41d9c513b7e8fee82aa494c5de5fdc8ddf2ae240 100644 (file)
@@ -696,7 +696,6 @@ static int si2168_probe(struct i2c_client *client,
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev) {
                ret = -ENOMEM;
-               dev_err(&client->dev, "kzalloc() failed\n");
                goto err;
        }
 
index 43d47dfcc7b85bef9e7cbad1d7a516262b6257ce..d3b4f882209667e60bee1cd451594c7939ce94d6 100644 (file)
@@ -384,7 +384,6 @@ static int sp2_probe(struct i2c_client *client,
        s = kzalloc(sizeof(struct sp2), GFP_KERNEL);
        if (!s) {
                ret = -ENOMEM;
-               dev_err(&client->dev, "kzalloc() failed\n");
                goto err;
        }
 
index f289b8aca1da818599aabe9fc277e8d6af667f56..5217f9ad5e6bc89debc0e66d6fd883fce5850dfe 100644 (file)
@@ -3316,10 +3316,8 @@ static int adv76xx_probe(struct i2c_client *client,
                        client->addr << 1);
 
        state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
-       if (!state) {
-               v4l_err(client, "Could not allocate adv76xx_state memory!\n");
+       if (!state)
                return -ENOMEM;
-       }
 
        state->i2c_clients[ADV76XX_PAGE_IO] = client;
 
index 65f34e7e146f25aa928cd57799bf3b6280a7d7d8..c582bcb782a614df4073669ae6f966a264eccf79 100644 (file)
@@ -3468,10 +3468,8 @@ static int adv7842_probe(struct i2c_client *client,
        }
 
        state = devm_kzalloc(&client->dev, sizeof(struct adv7842_state), GFP_KERNEL);
-       if (!state) {
-               v4l_err(client, "Could not allocate adv7842_state memory!\n");
+       if (!state)
                return -ENOMEM;
-       }
 
        /* platform data */
        state->pdata = *pdata;
index 8654710464cc14e24a8ce326abdcccaf5b6cc8ae..9e99c6ef1476be04f56a80469b06762eb917ece6 100644 (file)
@@ -910,11 +910,9 @@ static int cx18_probe(struct pci_dev *pci_dev,
        }
 
        cx = kzalloc(sizeof(struct cx18), GFP_ATOMIC);
-       if (cx == NULL) {
-               printk(KERN_ERR "cx18: cannot manage card %d, out of memory\n",
-                      i);
+       if (!cx)
                return -ENOMEM;
-       }
+
        cx->pci_dev = pci_dev;
        cx->instance = i;
 
index 11e987860b23ffc1d9b311b360c94d6aab5f02b8..0c91df34ec67127eaa4f4010641e9deacfe6edf0 100644 (file)
@@ -165,7 +165,6 @@ static int hopper_pci_probe(struct pci_dev *pdev,
 
        mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
        if (mantis == NULL) {
-               printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
                err = -ENOMEM;
                goto fail0;
        }
index adc980d3371186b34e5b62a8a7edbbf5f061d822..2dba030c7132191d636355412a0d76c60c59cebe 100644 (file)
@@ -174,10 +174,8 @@ static int mantis_pci_probe(struct pci_dev *pdev,
        int err = 0;
 
        mantis = kzalloc(sizeof(struct mantis_pci), GFP_KERNEL);
-       if (mantis == NULL) {
-               printk(KERN_ERR "%s ERROR: Out of memory\n", __func__);
+       if (!mantis)
                return -ENOMEM;
-       }
 
        drvdata                 = (void *)pci_id->driver_data;
        mantis->num             = devs;
index 49e047e4a81ee1dbce064c39c32a39be571182c0..af9cd02fac0cd115e522a9b9015206107f022b6c 100644 (file)
@@ -1626,23 +1626,18 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
        meye.mchip_dev = pcidev;
 
        meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
-       if (!meye.grab_temp) {
-               v4l2_err(v4l2_dev, "grab buffer allocation failed\n");
+       if (!meye.grab_temp)
                goto outvmalloc;
-       }
 
        spin_lock_init(&meye.grabq_lock);
        if (kfifo_alloc(&meye.grabq, sizeof(int) * MEYE_MAX_BUFNBRS,
-                               GFP_KERNEL)) {
-               v4l2_err(v4l2_dev, "fifo allocation failed\n");
+                       GFP_KERNEL))
                goto outkfifoalloc1;
-       }
+
        spin_lock_init(&meye.doneq_lock);
        if (kfifo_alloc(&meye.doneq, sizeof(int) * MEYE_MAX_BUFNBRS,
-                               GFP_KERNEL)) {
-               v4l2_err(v4l2_dev, "fifo allocation failed\n");
+                       GFP_KERNEL))
                goto outkfifoalloc2;
-       }
 
        meye.vdev = meye_template;
        meye.vdev.v4l2_dev = &meye.v4l2_dev;
index f708cab01fef1b5d77168ecd270f2cb922de8943..32c19bad9a17a130cd405dc26068e1d7406c2acc 100644 (file)
@@ -261,10 +261,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d
        DEB_EE("\n");
 
        hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
-       if (NULL == hexium) {
-               pr_err("not enough kernel memory in hexium_attach()\n");
+       if (!hexium)
                return -ENOMEM;
-       }
+
        dev->ext_priv = hexium;
 
        /* enable i2c-port pins */
index 01f01580c7cacd20f1679a063b4fcdc129f04ef3..8d1dc8eea98840b62aebd67e002596ce637542f3 100644 (file)
@@ -220,10 +220,8 @@ static int hexium_probe(struct saa7146_dev *dev)
        }
 
        hexium = kzalloc(sizeof(struct hexium), GFP_KERNEL);
-       if (NULL == hexium) {
-               pr_err("hexium_probe: not enough kernel memory\n");
+       if (!hexium)
                return -ENOMEM;
-       }
 
        /* enable i2c-port pins */
        saa7146_write(dev, MC1, (MASK_08 | MASK_24 | MASK_10 | MASK_26));
index a0d2129c6ca97ff0c464eace88904523cba69ac1..6bd665ea190d274dfc096f2d12d36620bf49f25d 100644 (file)
@@ -99,10 +99,8 @@ struct saa7164_buffer *saa7164_buffer_alloc(struct saa7164_port *port,
        }
 
        buf = kzalloc(sizeof(struct saa7164_buffer), GFP_KERNEL);
-       if (!buf) {
-               log_warn("%s() SAA_ERR_NO_RESOURCES\n", __func__);
+       if (!buf)
                goto ret;
-       }
 
        buf->idx = -1;
        buf->port = port;
index d7103c5f92c3b88e74641a6369a15871903d979f..db410c558a74d247623684868fa1dc4daafd4f4e 100644 (file)
@@ -1507,10 +1507,8 @@ static int isc_formats_init(struct isc_device *isc)
        isc->user_formats = devm_kcalloc(isc->dev,
                                         num_fmts, sizeof(struct isc_format *),
                                         GFP_KERNEL);
-       if (!isc->user_formats) {
-               v4l2_err(&isc->v4l2_dev, "could not allocate memory\n");
+       if (!isc->user_formats)
                return -ENOMEM;
-       }
 
        fmt = &isc_formats[0];
        for (i = 0, j = 0; i < ARRAY_SIZE(isc_formats); i++) {
index 891fa2505efa0a67d64330f979ad184b8c59c855..154e9c39b64f6c5df6503ee3922b47eff65955cb 100644 (file)
@@ -1038,10 +1038,8 @@ static int isi_formats_init(struct atmel_isi *isi)
        isi->user_formats = devm_kcalloc(isi->dev,
                                         num_fmts, sizeof(struct isi_format *),
                                         GFP_KERNEL);
-       if (!isi->user_formats) {
-               dev_err(isi->dev, "could not allocate memory\n");
+       if (!isi->user_formats)
                return -ENOMEM;
-       }
 
        memcpy(isi->user_formats, isi_fmts,
               num_fmts * sizeof(struct isi_format *));
@@ -1176,10 +1174,8 @@ static int atmel_isi_probe(struct platform_device *pdev)
        int ret, i;
 
        isi = devm_kzalloc(&pdev->dev, sizeof(struct atmel_isi), GFP_KERNEL);
-       if (!isi) {
-               dev_err(&pdev->dev, "Can't allocate interface!\n");
+       if (!isi)
                return -ENOMEM;
-       }
 
        isi->pclk = devm_clk_get(&pdev->dev, "isi_clk");
        if (IS_ERR(isi->pclk))
index 37169054b82888be7923c0d1a83751245a30710b..478eb2f7d723f657e85b36264ff38f698226c0bd 100644 (file)
@@ -338,7 +338,6 @@ struct ppi_if *ppi_create_instance(struct platform_device *pdev,
        ppi = kzalloc(sizeof(*ppi), GFP_KERNEL);
        if (!ppi) {
                peripheral_free_list(info->pin_req);
-               dev_err(&pdev->dev, "unable to allocate memory for ppi handle\n");
                return NULL;
        }
        ppi->ops = &ppi_ops;
index 4ff8d0aed015ce992e1b1f25dcac605153fafb6f..b50cff4ef9eb8c411cc39926f686f53ec1ec9d35 100644 (file)
@@ -209,10 +209,8 @@ static int send_control_msg(struct usb_device *udev, u8 request, u16 value,
        int status;
 
        unsigned char *transfer_buffer = kmalloc(size, GFP_KERNEL);
-       if (!transfer_buffer) {
-               dev_err(&udev->dev, "kmalloc(%d) failed\n", size);
+       if (!transfer_buffer)
                return -ENOMEM;
-       }
 
        memcpy(transfer_buffer, cp, size);
 
@@ -1424,10 +1422,8 @@ static int zr364xx_probe(struct usb_interface *intf,
                 le16_to_cpu(udev->descriptor.idProduct));
 
        cam = kzalloc(sizeof(struct zr364xx_camera), GFP_KERNEL);
-       if (cam == NULL) {
-               dev_err(&udev->dev, "cam: out of memory !\n");
+       if (!cam)
                return -ENOMEM;
-       }
 
        cam->v4l2_dev.release = zr364xx_release;
        err = v4l2_device_register(&intf->dev, &cam->v4l2_dev);