diff options
| author | Daniel Zahka <daniel.zahka@gmail.com> | 2026-09-03 18:33:59 -0700 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-09-07 16:38:37 -0700 |
| commit | 7b26ff20073901b4e7a0384464da784a5c94d56e (patch) | |
| tree | e28a7edcb882aa8042538fca3ba683ad6d1f9831 | |
| parent | 31f961de2f90fbf52eb2d4e15b3eeaa09f9b4fc2 (diff) | |
| download | linux-next-7b26ff20073901b4e7a0384464da784a5c94d56e.tar.gz linux-next-7b26ff20073901b4e7a0384464da784a5c94d56e.zip | |
psp: refactor psp_dev_tx_key_del()
No functional changes.
Lift the list deletion and tx spi validation code into
callers. Deferred key deletion code paths will need similar checks
that a tx key needs removal from the underlying device, but will
diverge when it comes to list handling and when to call
psp_dev_ops::tx_key_del().
Also, move the predicate for tx key deletion into a helper for
readability and reuse in later patches.
Signed-off-by: Daniel Zahka <daniel.zahka@gmail.com>
Link: https://patch.msgid.link/20260903-psp-prep-v1-1-d47e9c4c375d@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | net/psp/psp.h | 6 | ||||
| -rw-r--r-- | net/psp/psp_main.c | 7 | ||||
| -rw-r--r-- | net/psp/psp_sock.c | 11 |
3 files changed, 17 insertions, 7 deletions
diff --git a/net/psp/psp.h b/net/psp/psp.h index 86eeba823ced..8acf9ca84b55 100644 --- a/net/psp/psp.h +++ b/net/psp/psp.h @@ -53,4 +53,10 @@ static inline bool psp_dev_is_registered(struct psp_dev *psd) return !!psd->ops; } +static inline bool psp_assoc_needs_tx_key_del(struct psp_assoc *pas) +{ + lockdep_assert_held(&pas->psd->lock); + return pas->tx.spi; +} + #endif /* __PSP_PSP_H */ diff --git a/net/psp/psp_main.c b/net/psp/psp_main.c index c9c1a8826b7f..2556f0d46ef4 100644 --- a/net/psp/psp_main.c +++ b/net/psp/psp_main.c @@ -147,8 +147,11 @@ void psp_dev_unregister(struct psp_dev *psd) list_splice_init(&psd->active_assocs, &psd->prev_assocs); list_splice_init(&psd->prev_assocs, &psd->stale_assocs); - list_for_each_entry_safe(pas, next, &psd->stale_assocs, assocs_list) - psp_dev_tx_key_del(psd, pas); + list_for_each_entry_safe(pas, next, &psd->stale_assocs, assocs_list) { + if (psp_assoc_needs_tx_key_del(pas)) + psp_dev_tx_key_del(psd, pas); + list_del(&pas->assocs_list); + } list_for_each_entry_safe(entry, entry_tmp, &psd->assoc_dev_list, dev_list) { diff --git a/net/psp/psp_sock.c b/net/psp/psp_sock.c index 1a2a6b7516b0..045389671d7f 100644 --- a/net/psp/psp_sock.c +++ b/net/psp/psp_sock.c @@ -85,9 +85,7 @@ static int psp_dev_tx_key_add(struct psp_dev *psd, struct psp_assoc *pas, void psp_dev_tx_key_del(struct psp_dev *psd, struct psp_assoc *pas) { - if (pas->tx.spi) - psd->ops->tx_key_del(psd, pas); - list_del(&pas->assocs_list); + psd->ops->tx_key_del(psd, pas); } static void psp_assoc_free(struct work_struct *work) @@ -96,8 +94,11 @@ static void psp_assoc_free(struct work_struct *work) struct psp_dev *psd = pas->psd; mutex_lock(&psd->lock); - if (psp_dev_is_registered(psd)) - psp_dev_tx_key_del(psd, pas); + if (psp_dev_is_registered(psd)) { + if (psp_assoc_needs_tx_key_del(pas)) + psp_dev_tx_key_del(psd, pas); + list_del(&pas->assocs_list); + } mutex_unlock(&psd->lock); psp_dev_put(psd); kfree(pas); |
