diff options
author | Jakub Kicinski <kuba@kernel.org> | 2020-11-20 04:08:46 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2020-11-20 04:08:46 +0100 |
commit | 56495a2442a47d0ea752db62434913b3346fe5a5 (patch) | |
tree | 35284af165304f4fe47f0214a48a8708f76a0d28 /drivers/net/ipa | |
parent | r8153_ecm: avoid to be prior to r8152 driver (diff) | |
parent | Merge tag 'net-5.10-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/net... (diff) | |
download | linux-56495a2442a47d0ea752db62434913b3346fe5a5.tar.xz linux-56495a2442a47d0ea752db62434913b3346fe5a5.zip |
Merge https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'drivers/net/ipa')
-rw-r--r-- | drivers/net/ipa/gsi_trans.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/net/ipa/gsi_trans.c b/drivers/net/ipa/gsi_trans.c index 92642030e735..e8599bb948c0 100644 --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -362,22 +362,31 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id, return trans; } -/* Free a previously-allocated transaction (used only in case of error) */ +/* Free a previously-allocated transaction */ void gsi_trans_free(struct gsi_trans *trans) { + refcount_t *refcount = &trans->refcount; struct gsi_trans_info *trans_info; + bool last; - if (!refcount_dec_and_test(&trans->refcount)) + /* We must hold the lock to release the last reference */ + if (refcount_dec_not_one(refcount)) return; trans_info = &trans->gsi->channel[trans->channel_id].trans_info; spin_lock_bh(&trans_info->spinlock); - list_del(&trans->links); + /* Reference might have been added before we got the lock */ + last = refcount_dec_and_test(refcount); + if (last) + list_del(&trans->links); spin_unlock_bh(&trans_info->spinlock); + if (!last) + return; + ipa_gsi_trans_release(trans); /* Releasing the reserved TREs implicitly frees the sgl[] and |