Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

mailbox: mailbox-test: initialize struct earlier

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: 8ea4484d0c2b ("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>

authored by

Wolfram Sang and committed by
Jassi Brar
bbcf9af6 88ebadbf

+6 -7
+6 -7
drivers/mailbox/mailbox-test.c
··· 382 382 if (!tdev) 383 383 return -ENOMEM; 384 384 385 + tdev->dev = &pdev->dev; 386 + spin_lock_init(&tdev->lock); 387 + mutex_init(&tdev->mutex); 388 + init_waitqueue_head(&tdev->waitq); 389 + platform_set_drvdata(pdev, tdev); 390 + 385 391 /* It's okay for MMIO to be NULL */ 386 392 tdev->tx_mmio = mbox_test_ioremap(pdev, 0); 387 393 ··· 406 400 if (!tdev->rx_channel && (tdev->rx_mmio != tdev->tx_mmio)) 407 401 tdev->rx_channel = tdev->tx_channel; 408 402 409 - tdev->dev = &pdev->dev; 410 - platform_set_drvdata(pdev, tdev); 411 - 412 - spin_lock_init(&tdev->lock); 413 - mutex_init(&tdev->mutex); 414 - 415 403 if (tdev->rx_channel) { 416 404 tdev->rx_buffer = devm_kzalloc(&pdev->dev, 417 405 MBOX_MAX_MSG_LEN, GFP_KERNEL); ··· 419 419 if (ret) 420 420 goto err_free_chans; 421 421 422 - init_waitqueue_head(&tdev->waitq); 423 422 dev_info(&pdev->dev, "Successfully registered\n"); 424 423 425 424 return 0;