Skip to contentSkip to conversation

Staging: media: Replace dev_err with pr_err to avoid null pointer derefrence

PATCH New Haneen Mohammed 1 participant 1 message Mar 6, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: media: Replace dev_err with pr_err to avoid null pointer derefrence

This patch replace dev_err with pr_err, for pointer is derefrenced after comparing it to NULL. This was found using the following coccinelle script:

@disable is_null@
identifier f;
expression E;
identifier fld;
statement S;
@@

+ if(E == NULL) S

	f(...,E->fld,...);

-if(E == NULL) S;

@@
identifier f;
expression E;
identifier fld;
statement S;
@@

+ if(!E) S

	f(...,E->fld,...);

-if(!E) S;

---
 drivers/staging/media/lirc/lirc_zilog.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/media/lirc/lirc_zilog.c +1 -2
index abcc9e4..7318ff8 100644
@@ -1341,8 +1341,7 @@ static int close(struct inode *node, struct file *filep)
 	struct IR *ir = filep->private_data;
 
 	if (ir == NULL) {
-		dev_err(ir->l.dev,
-			"close: no private_data attached to the file!\n");
+		pr_err("ir: close: no private_data attached to the file!\n");
 		return -ENODEV;
 	}
 
Signature · 1 line
1.9.1