ALSA: firewire: Clean up a locking issue in copy_resp_to_buf()
Subsystems (3)
PATCH 1/1 ALSA: firewire: Clean up a locking issue in copy_resp_to_buf()
The spin_lock/unlock_irq() functions cannot be nested. The problem is that presumably we would want the IRQs to be re-enabled on the second call the spin_unlock_irq() but instead it will be enabled at the first call so IRQs will be enabled earlier than expected.
In this situation the copy_resp_to_buf() function is only called from one function and it is called with IRQs disabled. We can just use the regular spin_lock/unlock() functions.
--- sound/firewire/fireworks/fireworks_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
sound/firewire/fireworks/fireworks_transaction.c +2 -2
@@ -123,7 +123,7 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) t = (struct snd_efw_transaction *)data; length =min_t (size_t,be32_to_cpu (t->length) *sizeof (u32), length); -spin_lock_irq (&efw->lock); +spin_lock (&efw->lock);if (efw->push_ptr < efw->pull_ptr) capacity = (unsigned int )(efw->pull_ptr - efw->push_ptr);
@@ -190,7 +190,7 @@ handle_resp_for_user(struct fw_card *card, int generation, int source,copy_resp_to_buf (efw, data, length, rcode); end: -spin_unlock_irq (&instances_lock); +spin_unlock (&instances_lock); } static void
Signature · 1 line
2.28.0
Hi,
Quoted 9 lines · Dan Carpenter
The spin_lock/unlock_irq() functions cannot be nested. The problem is that presumably we would want the IRQs to be re-enabled on the second call the
spin_unlock_irq()but instead it will be enabled at the first call so IRQs will be enabled earlier than expected.In this situation the
copy_resp_to_buf()function is only called from one function and it is called with IRQs disabled. We can just use the regular spin_lock/unlock() functions.
Quoted 5 lines
Fixes 555e8a8f7f14 ("ALSA: fireworks: Add command/response functionality into hwdep interface")Signed-off-by Dan Carpenter <[email protected]>--- sound/firewire/fireworks/fireworks_transaction.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Indeed. It's bad to use the two pairs by nesting. Thanks for the patch and your care.
Quoted 24 lines
sound/firewire/fireworks/fireworks_transaction.c +2
-2@@ -123,7 +123,7 @@ copy_resp_to_buf(struct snd_efw *efw, void *data, size_t length, int *rcode) t = (struct snd_efw_transaction *)data; length =min_t (size_t,be32_to_cpu (t->length) *sizeof (u32), length); -spin_lock_irq (&efw->lock); +spin_lock (&efw->lock);if (efw->push_ptr < efw->pull_ptr) capacity = (unsigned int )(efw->pull_ptr - efw->push_ptr);@@ -190,7 +190,7 @@ handle_resp_for_user(struct fw_card *card, int generation, int source,copy_resp_to_buf (efw, data, length, rcode); end: -spin_unlock_irq (&instances_lock); +spin_unlock (&instances_lock); } static voidSignature · 1 line
2.28.0
Regards
Takashi Sakamoto
Takashi Iwai
AppliedQuoted 6 lines · Dan Carpenter
The spin_lock/unlock_irq() functions cannot be nested. The problem is that presumably we would want the IRQs to be re-enabled on the second call the
spin_unlock_irq()but instead it will be enabled at the first call so IRQs will be enabled earlier than expected.
Quoted 7 lines
In this situation the
copy_resp_to_buf()function is only called from one function and it is called with IRQs disabled. We can just use the regular spin_lock/unlock() functions.Fixes 555e8a8f7f14 ("ALSA: fireworks: Add command/response functionality into hwdep interface")Signed-off-by Dan Carpenter <[email protected]>---
Thanks, applied now with Cc to stable.
Takashi