Commit a1aae088 authored by simran singhal's avatar simran singhal Committed by Mauro Carvalho Chehab
Browse files

[media] staging: lirc_zilog: Clean up tests if NULL returned on failure



Some functions like kmalloc/kzalloc return NULL on failure.
When NULL represents failure, !x is commonly used.

This was done using Coccinelle:
@@
expression *e;
identifier l1;
@@

e = \(kmalloc\|kzalloc\|kcalloc\|devm_kzalloc\)(...);
...
- e == NULL
+ !e

Signed-off-by: default avatarsimran singhal <singhalsimran0@gmail.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 6eb1951d
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1475,7 +1475,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)
	ir = get_ir_device_by_adapter(adap);
	if (ir == NULL) {
		ir = kzalloc(sizeof(struct IR), GFP_KERNEL);
		if (ir == NULL) {
		if (!ir) {
			ret = -ENOMEM;
			goto out_no_ir;
		}
@@ -1515,7 +1515,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)

		/* Set up a struct IR_tx instance */
		tx = kzalloc(sizeof(struct IR_tx), GFP_KERNEL);
		if (tx == NULL) {
		if (!tx) {
			ret = -ENOMEM;
			goto out_put_xx;
		}
@@ -1559,7 +1559,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)

		/* Set up a struct IR_rx instance */
		rx = kzalloc(sizeof(struct IR_rx), GFP_KERNEL);
		if (rx == NULL) {
		if (!rx) {
			ret = -ENOMEM;
			goto out_put_xx;
		}