[SCSI] be2iscsi: Fix possible reentrancy issue in be_iopoll
authorShlomo Pongratz <[email protected]>
Sat, 6 Apr 2013 03:38:36 +0000 (20:38 -0700)
committerJames Bottomley <[email protected]>
Thu, 2 May 2013 15:17:54 +0000 (08:17 -0700)
The driver creates "NAPI" context per core which is fine,
however the above routine declares the ret variable as static!
Thus there is only one instance of this variable!
When this routine is called from more than one thread of execution,
than the result is unpredictable.

         static unsigned int ret;
         .....

         ret = beiscsi_process_cq(pbe_eq);
                 <--------Another thread can enter here and change "ret".
         if (ret < budget) {
                ....
         }
                 <--------Another thread can enter here and change "ret".
         return ret;

Fix - remove the "static"

Signed-off-by: Shlomo Pongratz <[email protected]>
Signed-off-by: Jayamohan Kallickal <[email protected]>
Reviewed-by: Mike Christie <[email protected]>
Signed-off-by: James Bottomley <[email protected]>
drivers/scsi/be2iscsi/be_main.c

index 228d3318191220cffbd303bf261ac43c0a9eaa0d..fe30e3fe7eed39bda2616200873a3fffd8f0827e 100644 (file)
@@ -2191,7 +2191,7 @@ void beiscsi_process_all_cqs(struct work_struct *work)
 
 static int be_iopoll(struct blk_iopoll *iop, int budget)
 {
-       static unsigned int ret;
+       unsigned int ret;
        struct beiscsi_hba *phba;
        struct be_eq_obj *pbe_eq;