move dereference after null check
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
Signed-off-by Dan Carpenter <[email protected]>
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) {
Quoted 13 lines · Dan Carpenter
I moved the
ops->inheritsdereference below the null check. I moved the other assignment as well so that they would be together.Found by smatch static checker.
regards,
dan carpenterSigned-off-by Dan Carpenter <[email protected]>
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