Skip to contentSkip to conversation

sctp: use sctp_auth_shkey_release() in error path for consistency

PATCH In review Wentao Liang 2 participants 2 messages Jun 22 – Jun 25

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sctp: use sctp_auth_shkey_release() in error path for consistency

Use the proper refcount-aware helper sctp_auth_shkey_release() instead of kfree() when freeing cur_key in the error path of sctp_auth_set_key(). While both are equivalent in the current code, using the helper maintains abstraction consistency and prevents potential issues if the code is reordered in the future.

---
 net/sctp/auth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sctp/auth.c +1 -1
index be9782760f50..84708f87392f 100644
@@ -753,7 +753,7 @@ int sctp_auth_set_key(struct sctp_endpoint *ep,
 	/* Create a new key data based on the info passed in */
 	key = sctp_auth_create_key(auth_key->sca_keylength, GFP_KERNEL);
 	if (!key) {
-		kfree(cur_key);
+		sctp_auth_shkey_release(cur_key);
 		return -ENOMEM;
 	}
 
Signature · 1 line
2.39.5 (Apple Git-154)
maintainer
#1 lore raw
Quoted 5 lines · On Mon, 22 Jun 2026 18:02:35 +0800 Wentao Liang wrote:

Use the proper refcount-aware helper sctp_auth_shkey_release() instead of kfree() when freeing cur_key in the error path of sctp_auth_set_key(). While both are equivalent in the current code, using the helper maintains abstraction consistency and prevents potential issues if the code is reordered in the future.

## Form letter - net-next-closed

We have already submitted our pull request with net-next material for v7.2, and therefore net-next is closed for new drivers, features, code refactoring and optimizations. We are currently accepting bug fixes only.

Please repost when net-next reopens after June 29th.

RFC patches sent for review only are obviously welcome at any time.

See: https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#development-cycle

Signature · 2 lines
pw-bot: defer
pv-bot: closed