diff mbox series

[net] ibmvnic: Free rwi on reset success

Message ID 20221031150642.13356-1-nnac123@linux.ibm.com (mailing list archive)
State Accepted
Commit d6dd2fe71153f0ff748bf188bd4af076fe09a0a6
Delegated to: Netdev Maintainers
Headers show
Series [net] ibmvnic: Free rwi on reset success | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers fail 3 blamed authors not CCed: drt@linux.ibm.com sukadev@linux.ibm.com davem@davemloft.net; 10 maintainers not CCed: linuxppc-dev@lists.ozlabs.org kuba@kernel.org drt@linux.ibm.com mpe@ellerman.id.au davem@davemloft.net npiggin@gmail.com christophe.leroy@csgroup.eu edumazet@google.com sukadev@linux.ibm.com pabeni@redhat.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 27 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Nick Child Oct. 31, 2022, 3:06 p.m. UTC
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>
---

Links to related discussions:
 - Same patch sent to net-next:
    https://lore.kernel.org/netdev/20221018130606.46c4ed3d@kernel.org/
 - Updated ibmvnic maintainers:
    https://lore.kernel.org/netdev/20221028203509.4070154-1-ricklind@us.ibm.com/

 drivers/net/ethernet/ibm/ibmvnic.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Nov. 3, 2022, 3:40 a.m. UTC | #1
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 31 Oct 2022 10:06:42 -0500 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - [net] ibmvnic: Free rwi on reset success
    https://git.kernel.org/netdev/net/c/d6dd2fe71153

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 65dbfbec487a..9282381a438f 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -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))