Commit dd9aa1f2 authored by Wolfram Sang's avatar Wolfram Sang Committed by Jassi Brar
Browse files

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: 8ea4484d ("mailbox: Add generic mechanism for testing Mailbox Controllers")
Fixes: 9b63a810 ("mailbox: mailbox-test: Fix an error check in mbox_test_probe()")
Signed-off-by: default avatarWolfram Sang <wsa+renesas@sang-engineering.com>
Reviewed-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: default avatarJassi Brar <jassisinghbrar@gmail.com>
parent a068c4d4
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -336,7 +336,7 @@ mbox_test_request_channel(struct platform_device *pdev, const char *name)

	client = devm_kzalloc(&pdev->dev, sizeof(*client), GFP_KERNEL);
	if (!client)
		return ERR_PTR(-ENOMEM);
		return NULL;

	client->dev		= &pdev->dev;
	client->rx_callback	= mbox_test_receive_message;
@@ -393,7 +393,7 @@ static int mbox_test_probe(struct platform_device *pdev)
	tdev->tx_channel = mbox_test_request_channel(pdev, "tx");
	tdev->rx_channel = mbox_test_request_channel(pdev, "rx");

	if (IS_ERR_OR_NULL(tdev->tx_channel) && IS_ERR_OR_NULL(tdev->rx_channel))
	if (!tdev->tx_channel && !tdev->rx_channel)
		return -EPROBE_DEFER;

	/* If Rx is not specified but has Rx MMIO, then Rx = Tx */