From nobody Tue Jun 16 05:18:38 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 71437328255 for ; Thu, 16 Apr 2026 11:47:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340078; cv=none; b=grbTDu/MPzRiBvwv/V1PImisCNdVWpSGyUj9z5X6KiigzG2HlopKHIZ9Av1hXRlsBp79tHvBOBh8nzrNyIZmWxDLFkh7cZsIGTT39B7YmaMGtamcTI3ZLMgKNWADVGfAybEJN8jkPHNRCPwQ7m6T8XZhpR9Ucezp9RcoJs7P+rE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340078; c=relaxed/simple; bh=IT+NlCmHLVTE6Bn99Sj8/QWHf+HwmtyMVzZ5DtwaRec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hngrreizxLKdQdqeeom5Kb5RjOl27SOMOBHOTTPUZc76IsTtUWidXQDSuAmSJZ/5a1Hc5W+kFiRQloPTOs1D3bnrrg51jsQbuqOlLjskF1BtCBFRaNQrs+fHkKZ9TE+nom1icEH+qOH+ouxm8NZSi4UTmZdKtMcyj2sYQJcl76I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=lSgLP+zP; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="lSgLP+zP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=SZCi506zO5K3gJw2C+jH3iA+bc33710B+OJBYI7JFh4=; b=lSgLP+ zPgW5ozqDjDIkVoGDAZvqkaXfmIbbohvJird26pkQ4sKn+2P6fgeXG/A2PDWCuI3 +M4YB2ovMiYuNvOGzs41/ACyh2TGFduG0vIk/WifBEY1x9Qwgkvt4tgajMuGEq4q YCYJckGrSnWIzZb+yP3TAZIsDgBcQ/F7P0CO8wROTK1L83MpVkdLE3VkC2HFYrOf Mn8tkeqciUZK4R9sS9Qva6pYRKVzPEx5kExVDPYWPgJE/nnFAt8K40lDCcT4/f6h uC65H5/C2Gw9tmJCRsf010uG9EZqE+rOLc4fS4vhvsMyB34yu8SdAV+baXCdUjfI WqNQzWSvpIjOB0YQ== Received: (qmail 3513090 invoked from network); 16 Apr 2026 13:47:46 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Apr 2026 13:47:46 +0200 X-UD-Smtp-Session: l3s3148p1@23mkZpJPMoEujnvW From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lee Jones , Wolfram Sang , Jassi Brar , Minjie Du Subject: [PATCH 1/3] mailbox: mailbox-test: handle channel errors consistently Date: Thu, 16 Apr 2026 13:47:34 +0200 Message-ID: <20260416114737.36988-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> References: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Co= ntrollers") Fixes: 9b63a810c6f9 ("mailbox: mailbox-test: Fix an error check in mbox_tes= t_probe()") Signed-off-by: Wolfram Sang Reviewed-by: Geert Uytterhoeven --- drivers/mailbox/mailbox-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 5e68f708205c..daf4b6f27d11 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -336,7 +336,7 @@ mbox_test_request_channel(struct platform_device *pdev,= const char *name) =20 client =3D devm_kzalloc(&pdev->dev, sizeof(*client), GFP_KERNEL); if (!client) - return ERR_PTR(-ENOMEM); + return NULL; =20 client->dev =3D &pdev->dev; client->rx_callback =3D mbox_test_receive_message; @@ -393,7 +393,7 @@ static int mbox_test_probe(struct platform_device *pdev) tdev->tx_channel =3D mbox_test_request_channel(pdev, "tx"); tdev->rx_channel =3D mbox_test_request_channel(pdev, "rx"); =20 - 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; =20 /* If Rx is not specified but has Rx MMIO, then Rx =3D Tx */ --=20 2.51.0 From nobody Tue Jun 16 05:18:38 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F221C346AC5 for ; Thu, 16 Apr 2026 11:47:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340077; cv=none; b=JU3/wO7KQ31OTemWaZmSOv+kvCfAjyVqJ//7jIuH0Rf3QtrqqauX9TroDhC02/U8uGNWdKEKjOdPObPxxEO4y9t0mnIrnOqfLQn2YiJf0CmMFhAywDhKx7uHbTSc8ECgqb8zzVIjd3DCAUlLlke9XnfCUtw0KZeiP3vyj4xmz7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340077; c=relaxed/simple; bh=0q6zAkbE2SG9nRMwwFfGhKrIGBhyItuN03BV0g+m0p4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BNKqcPw+l2lZ7UF8rLgCHq8J4bP34A7vCZI8Vc/AthZEh1CQ5rQLMFmx08Tr4H3QwCqU85uSXpBUMTuCMkJGheSQZjaNyqZPQOjaNUvgUxiP32pE+/xktQbLqfodHzcmMxXfqVjtq1Y1yBD5WVmBjqB2QObe9gPehaRlS603jSI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=Q4EWMAHj; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="Q4EWMAHj" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=9Q3+CBtz2OVL7c9MekVC9pbheFy+g+zG2ak1DrBaRRs=; b=Q4EWMA HjFJvcAKLLoFMT5IZ/cqH4ncz2ap6L2NidcfW8zgFADp6o0pa49NndVa+mE39kyl +K/iFhtvomIXVfmmAOhRBBNwnBj/m+UNPIlm/kn1iHzusi1iegiqwgEYkRu9SNVG 2V8/9mww+eVfvGW6r1zlW5Gt7xq/3opFr80IJlN/FvUSWstW8MY6YBG1efOjrhQK 5kxCMC20ZqSvBtnaVl6Xi1N/Ey6oOLAqgNJVEqEGLswWzD8S6EiOwDqv4U3HMy8P xfd7pJi2sO8fRlHQhBhb0XLn1TfC8oMq5evUs4LL4Xox9a3RIzF7P5vgJBfQuyM4 R+TCactOibkfVhqQ== Received: (qmail 3513129 invoked from network); 16 Apr 2026 13:47:47 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Apr 2026 13:47:47 +0200 X-UD-Smtp-Session: l3s3148p1@zlOwZpJPQIEujnvW From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lee Jones , Wolfram Sang , Jassi Brar Subject: [PATCH 2/3] mailbox: mailbox-test: don't free the reused channel Date: Thu, 16 Apr 2026 13:47:35 +0200 Message-ID: <20260416114737.36988-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> References: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The RX channel can be aliased to the TX channel if it has a different MMIO. This special case needs to be handled when freeing the channels otherwise a double-free occurs. Fixes: 8ea4484d0c2b ("mailbox: Add generic mechanism for testing Mailbox Co= ntrollers") Signed-off-by: Wolfram Sang --- drivers/mailbox/mailbox-test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index daf4b6f27d11..0a56b593fcac 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -427,7 +427,7 @@ static int mbox_test_probe(struct platform_device *pdev) err_free_chans: if (tdev->tx_channel) mbox_free_channel(tdev->tx_channel); - if (tdev->rx_channel) + if (tdev->rx_channel && tdev->rx_channel !=3D tdev->tx_channel) mbox_free_channel(tdev->rx_channel); return ret; } @@ -440,7 +440,7 @@ static void mbox_test_remove(struct platform_device *pd= ev) =20 if (tdev->tx_channel) mbox_free_channel(tdev->tx_channel); - if (tdev->rx_channel) + if (tdev->rx_channel && tdev->rx_channel !=3D tdev->tx_channel) mbox_free_channel(tdev->rx_channel); } =20 --=20 2.51.0 From nobody Tue Jun 16 05:18:38 2026 Received: from mail.zeus03.de (zeus03.de [194.117.254.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4BFB83845D9 for ; Thu, 16 Apr 2026 11:47:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=194.117.254.33 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340078; cv=none; b=kETC7fMhpx6vEM35PWdRrQ/zQH1Rmpz4QIgP98h81z/vo9NlRuZ42ltHLO3wVD1a5cFnZkFbrcRfiRnLcoQNIOGvv8tLgTqD1FiGV8pIkvu6mbGs6+gcTsF4aJSQVgwVGrT0IGMFh74G+LYAr82bwG/hgeDKGjpgHQBsQIu4zH4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776340078; c=relaxed/simple; bh=/VIfZsa4oqyvmID8SKfKFqPFfjVeD2x58CXni9M1Crs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T7WeJqCs2tqICqAYoO7+lE6aKI+dTzi63aEuLd5IXjcJpT4dZ0iw5dZ1h/INWWwXCo9M8/F4Gb4fIc+vG3tLrvQVs84T+1Z8lWuHfxa71b8AdeNIZjh8V8mvHwH1/fzTBs0cGSHgyFGT+zw0G36cSvwOtBoYTLlxR401/2eDRno= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com; spf=pass smtp.mailfrom=sang-engineering.com; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b=VBuMy9uz; arc=none smtp.client-ip=194.117.254.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sang-engineering.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=sang-engineering.com header.i=@sang-engineering.com header.b="VBuMy9uz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= sang-engineering.com; h=from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; s=k1; bh=3oA7U2aq32kQK/yDgGBbgWts3bDU59r35/25VsRfZmI=; b=VBuMy9 uz4to9Mxx51cOH/87ox5tSk8JCWgc8Zx8uAtdutc6wsBcjfIWa63PKE4Iwyqe0Ky RE6mGH8A3PrhGJshXfs3Mm0tIM8+cQtSKCDNidkW1pfroixXzd4aCtoMFtyXdppm eBArREML1QR+7UX6qybuGtQqRZgqWzHYaF/Qc2z8PmchtJZpC29NhzwnEQg0a1lx cOWypFdkypIaqx+7sVj8O8k86q2MNh7ro7iNHPLvh1qq1fwgVGBbN8evpb9I512+ I+AKtVZ49eZ0R0qNm3JKdcpoIo0wnrGW1LXDTjtkFtYPnVZtuJkI3x7HsWneISUQ u3JMFqkUhlV7xjgA== Received: (qmail 3513159 invoked from network); 16 Apr 2026 13:47:48 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Apr 2026 13:47:48 +0200 X-UD-Smtp-Session: l3s3148p1@CrDAZpJPToEujnvW From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Lee Jones , Wolfram Sang , Jassi Brar Subject: [PATCH 3/3] mailbox: mailbox-test: initialize struct earlier Date: Thu, 16 Apr 2026 13:47:36 +0200 Message-ID: <20260416114737.36988-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> References: <20260416114737.36988-1-wsa+renesas@sang-engineering.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The workqueue 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 Co= ntrollers") Signed-off-by: Wolfram Sang --- drivers/mailbox/mailbox-test.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index 0a56b593fcac..ec591616fe46 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -382,6 +382,12 @@ static int mbox_test_probe(struct platform_device *pde= v) if (!tdev) return -ENOMEM; =20 + tdev->dev =3D &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 */ tdev->tx_mmio =3D mbox_test_ioremap(pdev, 0); =20 @@ -400,12 +406,6 @@ static int mbox_test_probe(struct platform_device *pde= v) if (!tdev->rx_channel && (tdev->rx_mmio !=3D tdev->tx_mmio)) tdev->rx_channel =3D tdev->tx_channel; =20 - tdev->dev =3D &pdev->dev; - platform_set_drvdata(pdev, tdev); - - spin_lock_init(&tdev->lock); - mutex_init(&tdev->mutex); - if (tdev->rx_channel) { tdev->rx_buffer =3D 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; =20 - init_waitqueue_head(&tdev->waitq); dev_info(&pdev->dev, "Successfully registered\n"); =20 return 0; --=20 2.51.0