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: handle channel errors consistently

mbox_test_request_channel() returns either an ERR_PTR or NULL. The
callers, however, mostly checked for non-NULL which allows for bogus
code paths when an ERR_PTR is treated like a valid channel. A later
commit tried to fix it in one place but missed the other ones. Because
the ERR_PTR is only used for -ENOMEM once and is converted to
-EPROBE_DEFER anyhow, convert the callee to only return NULL which
simplifies handling a lot and makes it less error prone.

Fixes: 8ea4484d0c2b ("mailbox: Add generic mechanism for testing Mailbox Controllers")
Fixes: 9b63a810c6f9 ("mailbox: mailbox-test: Fix an error check in mbox_test_probe()")
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>

authored by

Wolfram Sang and committed by
Jassi Brar
dd9aa1f2 a068c4d4

+2 -2
+2 -2
drivers/mailbox/mailbox-test.c
··· 336 336 337 337 client = devm_kzalloc(&pdev->dev, sizeof(*client), GFP_KERNEL); 338 338 if (!client) 339 - return ERR_PTR(-ENOMEM); 339 + return NULL; 340 340 341 341 client->dev = &pdev->dev; 342 342 client->rx_callback = mbox_test_receive_message; ··· 393 393 tdev->tx_channel = mbox_test_request_channel(pdev, "tx"); 394 394 tdev->rx_channel = mbox_test_request_channel(pdev, "rx"); 395 395 396 - if (IS_ERR_OR_NULL(tdev->tx_channel) && IS_ERR_OR_NULL(tdev->rx_channel)) 396 + if (!tdev->tx_channel && !tdev->rx_channel) 397 397 return -EPROBE_DEFER; 398 398 399 399 /* If Rx is not specified but has Rx MMIO, then Rx = Tx */