]> git.dujemihanovic.xyz Git - linux.git/commitdiff
ibmvnic: Free rwi on reset success
authorNick Child <nnac123@linux.ibm.com>
Mon, 31 Oct 2022 15:06:42 +0000 (10:06 -0500)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Nov 2022 03:30:51 +0000 (20:30 -0700)
Free the rwi structure in the event that the last rwi in the list
processed successfully. The logic in commit 4f408e1fa6e1 ("ibmvnic:
retry reset if there are no other resets") introduces an issue that
results in a 32 byte memory leak whenever the last rwi in the list
gets processed.

Fixes: 4f408e1fa6e1 ("ibmvnic: retry reset if there are no other resets")
Signed-off-by: Nick Child <nnac123@linux.ibm.com>
Link: https://lore.kernel.org/r/20221031150642.13356-1-nnac123@linux.ibm.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/ibm/ibmvnic.c

index 65dbfbec487a34b6af65538434c0d429e9fade46..9282381a438fe97594c3025be7fa618205f401b6 100644 (file)
@@ -3007,19 +3007,19 @@ static void __ibmvnic_reset(struct work_struct *work)
                rwi = get_next_rwi(adapter);
 
                /*
-                * If there is another reset queued, free the previous rwi
-                * and process the new reset even if previous reset failed
-                * (the previous reset could have failed because of a fail
-                * over for instance, so process the fail over).
-                *
                 * If there are no resets queued and the previous reset failed,
                 * the adapter would be in an undefined state. So retry the
                 * previous reset as a hard reset.
+                *
+                * Else, free the previous rwi and, if there is another reset
+                * queued, process the new reset even if previous reset failed
+                * (the previous reset could have failed because of a fail
+                * over for instance, so process the fail over).
                 */
-               if (rwi)
-                       kfree(tmprwi);
-               else if (rc)
+               if (!rwi && rc)
                        rwi = tmprwi;
+               else
+                       kfree(tmprwi);
 
                if (rwi && (rwi->reset_reason == VNIC_RESET_FAILOVER ||
                            rwi->reset_reason == VNIC_RESET_MOBILITY || rc))