Skip to content

Commit 9011bc6

Browse files
elfringehristev
authored andcommitted
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: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Hans Verkuil <hansverk@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
1 parent a16134b commit 9011bc6

23 files changed

Lines changed: 30 additions & 80 deletions

File tree

drivers/media/common/cypress_firmware.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,8 @@ int cypress_load_firmware(struct usb_device *udev,
7575
int ret, pos = 0;
7676

7777
hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
78-
if (!hx) {
79-
dev_err(&udev->dev, "%s: kmalloc() failed\n", KBUILD_MODNAME);
78+
if (!hx)
8079
return -ENOMEM;
81-
}
8280

8381
/* stop the CPU */
8482
hx->data[0] = 1;

drivers/media/common/siano/smscoreapi.c

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,10 +1301,8 @@ static int smscore_init_device(struct smscore_device_t *coredev, int mode)
13011301

13021302
buffer = kmalloc(sizeof(struct sms_msg_data) +
13031303
SMS_DMA_ALIGNMENT, GFP_KERNEL | GFP_DMA);
1304-
if (!buffer) {
1305-
pr_err("Could not allocate buffer for init device message.\n");
1304+
if (!buffer)
13061305
return -ENOMEM;
1307-
}
13081306

13091307
msg = (struct sms_msg_data *)SMS_ALIGN_ADDRESS(buffer);
13101308
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,
16871685
return -EEXIST;
16881686
}
16891687
listentry = kzalloc(sizeof(struct smscore_idlist_t), GFP_KERNEL);
1690-
if (!listentry) {
1691-
pr_err("Can't allocate memory for client id.\n");
1688+
if (!listentry)
16921689
return -ENOMEM;
1693-
}
1690+
16941691
listentry->id = id;
16951692
listentry->data_type = data_type;
16961693
list_add_locked(&listentry->entry, &client->idlist,
@@ -1725,10 +1722,8 @@ int smscore_register_client(struct smscore_device_t *coredev,
17251722
}
17261723

17271724
newclient = kzalloc(sizeof(struct smscore_client_t), GFP_KERNEL);
1728-
if (!newclient) {
1729-
pr_err("Failed to allocate memory for client.\n");
1725+
if (!newclient)
17301726
return -ENOMEM;
1731-
}
17321727

17331728
INIT_LIST_HEAD(&newclient->idlist);
17341729
newclient->coredev = coredev;

drivers/media/dvb-frontends/as102_fe.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,9 @@ struct dvb_frontend *as102_attach(const char *name,
456456
struct dvb_frontend *fe;
457457

458458
state = kzalloc(sizeof(struct as102_state), GFP_KERNEL);
459-
if (state == NULL) {
460-
pr_err("%s: unable to allocate memory for state\n", __func__);
459+
if (!state)
461460
return NULL;
462-
}
461+
463462
fe = &state->frontend;
464463
fe->demodulator_priv = state;
465464
state->ops = ops;

drivers/media/dvb-frontends/cx24113.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -555,10 +555,9 @@ struct dvb_frontend *cx24113_attach(struct dvb_frontend *fe,
555555
struct cx24113_state *state =
556556
kzalloc(sizeof(struct cx24113_state), GFP_KERNEL);
557557
int rc;
558-
if (state == NULL) {
559-
cx_err("Unable to kzalloc\n");
558+
559+
if (!state)
560560
goto error;
561-
}
562561

563562
/* setup the state */
564563
state->config = config;

drivers/media/dvb-frontends/cx24116.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ static int cx24116_writeregN(struct cx24116_state *state, int reg,
227227

228228
buf = kmalloc(len + 1, GFP_KERNEL);
229229
if (buf == NULL) {
230-
printk("Unable to kmalloc\n");
231230
ret = -ENOMEM;
232231
goto error;
233232
}

drivers/media/dvb-frontends/drxd_hard.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,6 @@ static int load_firmware(struct drxd_state *state, const char *fw_name)
911911
state->microcode = kmemdup(fw->data, fw->size, GFP_KERNEL);
912912
if (state->microcode == NULL) {
913913
release_firmware(fw);
914-
printk(KERN_ERR "drxd: firmware load failure: no memory\n");
915914
return -ENOMEM;
916915
}
917916

drivers/media/dvb-frontends/ds3000.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,8 @@ static int ds3000_writeFW(struct ds3000_state *state, int reg,
277277
u8 *buf;
278278

279279
buf = kmalloc(33, GFP_KERNEL);
280-
if (buf == NULL) {
281-
printk(KERN_ERR "Unable to kmalloc\n");
280+
if (!buf)
282281
return -ENOMEM;
283-
}
284282

285283
*(buf) = reg;
286284

@@ -842,10 +840,8 @@ struct dvb_frontend *ds3000_attach(const struct ds3000_config *config,
842840

843841
/* allocate memory for the internal state */
844842
state = kzalloc(sizeof(struct ds3000_state), GFP_KERNEL);
845-
if (state == NULL) {
846-
printk(KERN_ERR "Unable to kmalloc\n");
843+
if (!state)
847844
goto error2;
848-
}
849845

850846
state->config = config;
851847
state->i2c = i2c;

drivers/media/dvb-frontends/mb86a20s.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,11 +2072,8 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,
20722072

20732073
/* allocate memory for the internal state */
20742074
state = kzalloc(sizeof(struct mb86a20s_state), GFP_KERNEL);
2075-
if (state == NULL) {
2076-
dev_err(&i2c->dev,
2077-
"%s: unable to allocate memory for state\n", __func__);
2075+
if (!state)
20782076
goto error;
2079-
}
20802077

20812078
/* setup the state */
20822079
state->config = config;

drivers/media/dvb-frontends/si2168.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,6 @@ static int si2168_probe(struct i2c_client *client,
696696
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
697697
if (!dev) {
698698
ret = -ENOMEM;
699-
dev_err(&client->dev, "kzalloc() failed\n");
700699
goto err;
701700
}
702701

drivers/media/dvb-frontends/sp2.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,6 @@ static int sp2_probe(struct i2c_client *client,
384384
s = kzalloc(sizeof(struct sp2), GFP_KERNEL);
385385
if (!s) {
386386
ret = -ENOMEM;
387-
dev_err(&client->dev, "kzalloc() failed\n");
388387
goto err;
389388
}
390389

0 commit comments

Comments
 (0)