Skip to contentSkip to conversation

move dereference after null check

PATCH In review Dan Carpenter 2 participants 2 messages Nov 10, 2009 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 move dereference after null check

I moved the ops->inherits dereference below the null check. I moved the other assignment as well so that they would be together.

Found by smatch static checker.

regards,
dan carpenter

drivers/ata/libata-core.c +4 -3
@@ -5938,13 +5938,14 @@
 {
 	static DEFINE_SPINLOCK(lock);
 	const struct ata_port_operations *cur;
-	void **begin = (void **)ops;
-	void **end = (void **)&ops->inherits;
-	void **pp;
+	void **begin, **end, **pp;
 
 	if (!ops || !ops->inherits)
 		return;
 
+	begin = (void **)ops;
+	end = (void **)&ops->inherits;
+
 	spin_lock(&lock);
 
 	for (cur = ops->inherits; cur; cur = cur->inherits) {
#1 lore raw
Quoted 13 lines · Dan Carpenter

I moved the ops->inherits dereference below the null check. I moved the other assignment as well so that they would be together.

Found by smatch static checker.

regards,
dan carpenter

drivers/ata/libata-core.c line 5942

Quoted 5 lines
drivers/ata/libata-core.c +0 -2
@@ -5938,13 +5938,14 @@
 {
 	static DEFINE_SPINLOCK(lock);
 	const struct ata_port_operations *cur;
-	void **begin = (void **)ops;
-	void **end = (void **)&ops->inherits;

There's no problem here: this isn't a dereference.

James