]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mailbox: Not protect module_put with spin_lock_irqsave
authorPeng Fan <peng.fan@nxp.com>
Fri, 11 Apr 2025 13:14:10 +0000 (21:14 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:27:36 +0000 (18:27 +0200)
[ Upstream commit dddbd233e67e792bb0a3f9694a4707e6be29b2c6 ]

&chan->lock is not supposed to protect 'chan->mbox'.
And in __mbox_bind_client, try_module_get is also not protected
by &chan->lock. So move module_put out of the lock protected
region.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/mailbox/mailbox.c

index 6f54501dc7762afcd3f8ded0cc27672ec8e0a001..cb31ad917b352fd4f6135939ddc80e452b1d4c1a 100644 (file)
@@ -459,8 +459,8 @@ void mbox_free_channel(struct mbox_chan *chan)
        if (chan->txdone_method == TXDONE_BY_ACK)
                chan->txdone_method = TXDONE_BY_POLL;
 
-       module_put(chan->mbox->dev->driver->owner);
        spin_unlock_irqrestore(&chan->lock, flags);
+       module_put(chan->mbox->dev->driver->owner);
 }
 EXPORT_SYMBOL_GPL(mbox_free_channel);