scsi: zfcp: Use list_first_entry_or_null() in zfcp_erp_thread()
authorJulian Wiedmann <jwi@linux.ibm.com>
Thu, 10 Sep 2020 19:49:15 +0000 (21:49 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 15 Sep 2020 22:01:57 +0000 (18:01 -0400)
Use the right helper to avoid poking around in the list's internals.

Link: https://lore.kernel.org/r/ed669555c73aab95b29444c10066f492c0c43391.1599765652.git.bblock@linux.ibm.com
Reviewed-by: Steffen Maier <maier@linux.ibm.com>
Reviewed-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: Benjamin Block <bblock@linux.ibm.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/s390/scsi/zfcp_erp.c

index 59e662df5774f867876e3a35a698824d332120f1..78d52a4c55f526fb085ff9f0599da9e71a6b5aab 100644 (file)
@@ -1607,7 +1607,6 @@ check_target:
 static int zfcp_erp_thread(void *data)
 {
        struct zfcp_adapter *adapter = (struct zfcp_adapter *) data;
-       struct list_head *next;
        struct zfcp_erp_action *act;
        unsigned long flags;
 
@@ -1620,12 +1619,11 @@ static int zfcp_erp_thread(void *data)
                        break;
 
                write_lock_irqsave(&adapter->erp_lock, flags);
-               next = adapter->erp_ready_head.next;
+               act = list_first_entry_or_null(&adapter->erp_ready_head,
+                                              struct zfcp_erp_action, list);
                write_unlock_irqrestore(&adapter->erp_lock, flags);
 
-               if (next != &adapter->erp_ready_head) {
-                       act = list_entry(next, struct zfcp_erp_action, list);
-
+               if (act) {
                        /* there is more to come after dismission, no notify */
                        if (zfcp_erp_strategy(act) != ZFCP_ERP_DISMISSED)
                                zfcp_erp_wakeup(adapter);