mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 12:01:07 +00:00
mailbox: mailbox-test: initialize struct earlier
[ Upstream commit bbcf9af68bfedb3d9cc3c7eae62f5c844d8b78b9 ]
The waitqueue must be initialized before the debugfs files are created
because from that time, requests from userspace can already be made.
Similarily, drvdata and spinlock needs to be initialized before we
request the channel, otherwise dangling irqs might run into problems
like a NULL pointer exception.
Fixes: 8ea4484d0c ("mailbox: Add generic mechanism for testing Mailbox Controllers")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
dd5648d3af
commit
f6ebe7b378
@ -369,6 +369,12 @@ static int mbox_test_probe(struct platform_device *pdev)
|
||||
if (!tdev)
|
||||
return -ENOMEM;
|
||||
|
||||
tdev->dev = &pdev->dev;
|
||||
spin_lock_init(&tdev->lock);
|
||||
mutex_init(&tdev->mutex);
|
||||
init_waitqueue_head(&tdev->waitq);
|
||||
platform_set_drvdata(pdev, tdev);
|
||||
|
||||
/* It's okay for MMIO to be NULL */
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
tdev->tx_mmio = devm_ioremap_resource(&pdev->dev, res);
|
||||
@ -400,12 +406,6 @@ static int mbox_test_probe(struct platform_device *pdev)
|
||||
if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio))
|
||||
tdev->rx_channel = tdev->tx_channel;
|
||||
|
||||
tdev->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, tdev);
|
||||
|
||||
spin_lock_init(&tdev->lock);
|
||||
mutex_init(&tdev->mutex);
|
||||
|
||||
if (tdev->rx_channel) {
|
||||
tdev->rx_buffer = devm_kzalloc(&pdev->dev,
|
||||
MBOX_MAX_MSG_LEN, GFP_KERNEL);
|
||||
@ -419,7 +419,6 @@ static int mbox_test_probe(struct platform_device *pdev)
|
||||
if (ret)
|
||||
goto err_free_chans;
|
||||
|
||||
init_waitqueue_head(&tdev->waitq);
|
||||
dev_info(&pdev->dev, "Successfully registered\n");
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user