From nobody Tue Jun 16 05:18:39 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 83A6437A4BA for ; Fri, 17 Apr 2026 07:42:42 +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=1776411767; cv=none; b=emfvOh67LNfJWo91RFn7Q4UvZThLmQpMSC6DXtRYD9eyYRNHfI7pRbSCOoPutwD4xtrurwd51cSgz4To6M8ltXusjF0akO33QdkwbqNBo3+PNRWJdAuAeHEjkqBmcPmMmzSwcN8BcDXOCY+5TuLtd4SPpPE9vM/RFA1JhzZX5hE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411767; c=relaxed/simple; bh=+vgEkieG5Z9Qf+OlzIt61SgEsO/ihWEqCLPih5uvYOk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bD0iwK4gOiuCB37l7WiNDoOa+WNBaka7TS1IuzoEJtLii1TFcr06QMjd0iuQ/aeKCVFPc/qd2JISSewd0RMeNz+kdTTT4LxysVIXqqGpe5dm8jGBYHnnng5qeuEQy5RmodC40WJ0TmROfwTNjfTXpxvNgqodUt/qmliDcfzoSa8= 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=FhGZsAw8; 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="FhGZsAw8" 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=23AIyKmewb4aRL/ytqe4GU7fSGbIP3y9jZWV3lvCF1o=; b=FhGZsA w8RADcwFHnzFmn2ZA5wZZkwI47UtlkP4L6rfwUS2hD38nULyaCVIm3L6vhQ6EW38 b+GZKjnvEB5v/HhDqMgcEflrOgrk7CegJgxdb/WvTCwUVOaPGk8FBn9QvXLtamlY 3VG/4Rrxon106cpSmkGryeIAWrlfReocEDleoLm4HdllhSjW7Ayb4JYbY3aeCT9M W1IgPrMXUMCp8GRjRbEn0TCgcVLFaDkvY7Liz7MokZ8wUrupaaQI3EtYGiywDOfc B6fz1q+yDWYi2v6mB1sASR3jI5HjGrBk10/Cp7k4NTUkduqS7ocxdGdk+fokglYG 6n08ZPDnwmV3tthQ== Received: (qmail 3855937 invoked from network); 17 Apr 2026 09:42:40 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 Apr 2026 09:42:40 +0200 X-UD-Smtp-Session: l3s3148p1@fcrzF6NPD1NtKXL4 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sudeep Holla , Wolfram Sang , Geert Uytterhoeven , Jassi Brar , Lee Jones , Minjie Du Subject: [PATCH v2 1/4] mailbox: mailbox-test: handle channel errors consistently Date: Fri, 17 Apr 2026 09:42:33 +0200 Message-ID: <20260417074237.16053-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417074237.16053-1-wsa+renesas@sang-engineering.com> References: <20260417074237.16053-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:39 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 8C30037996C for ; Fri, 17 Apr 2026 07:42:43 +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=1776411766; cv=none; b=nJDrHo+HHcdeDooRDfwao6/XiIJUEanGh6ofCF/OKXjsaqWO3kve9rqZQ6Fbd3yfnJQ4K4+Pr6vTSq+pOETgCEA9O050KdPiC1qj9bx1N5om6SakOVGNiyYKhHq9cGUGobfV17ESa9yPP3yGNwk39hQE93QiIBi2xeDsjU+2Xww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411766; c=relaxed/simple; bh=0q6zAkbE2SG9nRMwwFfGhKrIGBhyItuN03BV0g+m0p4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ob9ZHcvFD6F0cEJ9s83/SzXNS6ezXuxXDRA7i9NqXxFh4Qz7Ep621nUpOFr8ZqmO2oHFq2xaYBr+5yL9uzC8HLwsBKAeYW/cSDHiKlJXSqhjgiY8WJYMeW6Kl6h9eq6EMSx91Ki+UuBvBbg3/q6J9RlpNT3ue9YgF8dBEx+mgbk= 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=DDiekaWM; 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="DDiekaWM" 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=DDieka WM7/PDEVBv61eBVusqtwcM6Tp9BUhO8icFimvm8uHOtM6BmMoftLpKp+cZkxZAuE f+YYENuhbGJmrxKsq9elBd9SGZJzG3nXCLf9Jh5mLh5XKr3tSVa0QRjEncm+s79m 6aFqnNqNXpXmhPUdE2xTSDjo1p9OIfhN4yiBQhU2PgYSEQED57oy7VlNrXn9t77U wKvljkrt1laisGquBkoZ7yF4p/adpCQvhOzT77cAwDa4A3a8Y5cH51Csn2lpUaH/ Q47Su6nmgXz++9rpM0DAWqBbS23qb9wo6QeXd7X1FPpqNTpSsf4+FZutztHT++Dq m8fW8CMtvc6cjLNw== Received: (qmail 3855983 invoked from network); 17 Apr 2026 09:42:41 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 Apr 2026 09:42:41 +0200 X-UD-Smtp-Session: l3s3148p1@NNsCGKNP6jxtKXL4 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sudeep Holla , Wolfram Sang , Jassi Brar , Lee Jones Subject: [PATCH v2 2/4] mailbox: mailbox-test: don't free the reused channel Date: Fri, 17 Apr 2026 09:42:34 +0200 Message-ID: <20260417074237.16053-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417074237.16053-1-wsa+renesas@sang-engineering.com> References: <20260417074237.16053-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:39 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 A853F37B02D for ; Fri, 17 Apr 2026 07:42:44 +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=1776411770; cv=none; b=fvT98um1hKZ/Lxn2zTk8xnynqC+/FK048L3FO45BOlZnxpJhEPSsFd3Rof6gjAGLBJz+M32yHLc7xCz+ml8CMxzvWUxSnk+ur22E595OHLZS9gMOD2kFI7YiEjlEOiyYCImY77leMBYD4om4Qi0T3MRG7vgjmuvJMNs8srGVFx4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411770; c=relaxed/simple; bh=PdR0t6PIPrfwC1VtD4zPq/c3A3Hha66LQa/sH7nzyas=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oSg6KH1h1AaIfrrw+PD9ghDKmOrJ1ai5KXr+8oOqWS+fKCzIpaU3A7XXjRLcLsSz0jn4zupd/sJD9YdzDWvLQYJdjE4L5ZvRnvZpkjB9/caGsgfBltqXQJR2A+PoHATes2ZnaRH4OTC0NIzCawzPCRg7sWo3GYmn05vmdH0zIxs= 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=icPlPV29; 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="icPlPV29" 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=ttbAflTbp0B7HiuzcNLymn4toX13Ln+9145vIJ0/gvE=; b=icPlPV 294iKY0rGL9nJyKu+N15xmZS6foDslcev9dSOFRbvlMxBoHm42zavsSUR82jJ0ie QMT5ZQHuNQe9AqRGVWBHsm6HzQZfExifJB+y4FLATq4dQKLyOIL8jYpOFFM0Y0z6 4lRDvILfzeo5BO+QRc5DI5bvCV0JQm4OYMYAcJJJ9R4E0a+MPZ9mpAOXRKvF5sdu UPWTHB4eq54DELoBKz8aJ7+AOM9t61LLClZEmY3thbrICXXBYrzM46e5BY7a4aX5 vyjnPmKt7V//KDmGivBccU4bnru6X0WjKdO6l3UkKfT+5I16doe6snag3CcK8B/f 5sPmFPohXQCWCCYg== Received: (qmail 3856016 invoked from network); 17 Apr 2026 09:42:42 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 Apr 2026 09:42:42 +0200 X-UD-Smtp-Session: l3s3148p1@paURGKNP6lltKXL4 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sudeep Holla , Wolfram Sang , Jassi Brar , Lee Jones Subject: [PATCH v2 3/4] mailbox: mailbox-test: initialize struct earlier Date: Fri, 17 Apr 2026 09:42:35 +0200 Message-ID: <20260417074237.16053-4-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417074237.16053-1-wsa+renesas@sang-engineering.com> References: <20260417074237.16053-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 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 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 From nobody Tue Jun 16 05:18:39 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 7A676343D9E for ; Fri, 17 Apr 2026 07:42:45 +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=1776411770; cv=none; b=dE6ihz8w7FEieUxraSO8/gGoGeSERx3OV97WJY4n+DkvxWd6kdgCkV5cprKvg9vmqoduG4VE4AHQqH1MxtmRI4UMBXkvkaXITqEhT9ps12fFi/kc5SVRy5WGsWhQdblNcguk0djXr77Y+Mdzn4pAAy0t1idwahTbW598edrlZpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776411770; c=relaxed/simple; bh=knJEA8B7QZxEh/kqQU2DgntgYWOWeRF/alFzEQG6sWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Tp+E3HU0wgX2RabN4bQKAetyYgIXDwc12ePLdoizYBbDwqmNoK4sDD0Bxyf3o92u29TCvefnbHFSftrTr619OjykA7hMhASQTcsvobEBuznNjh+KC7SsGQjLaRa3DF/57INN7zZCwfDd7ca28Kr6M7xCN05MfWl7P+S6R90PFw4= 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=XMeMAmLf; 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="XMeMAmLf" 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=39c9RleYighhBE6xhQNEebfpiH1/xpyXp2eDLj7h3gU=; b=XMeMAm Lff8XFeLmAKF2WWE7XH5/MpmT1cDbS1wBdUEFrOrkeiO2Mu2rVLHVw8eqrTqdKvx xouNckrjfkQawIwKc4WLzNoVyo9tAIaAHz/j6GU1dBYQu8OhRNjkYnRXUDk9VWXE pT8+h4RNYcIWbF4j0d5HzNzSitdghblz7Rv8eL901UFZsTg4qAa0exK2k03Eq8qG SqXg11loRNM+Ki2Dl9ZCpFVohantXtaOnRuyfzGGKUYHqLaJQQwnO9VuWNRfWd0L 5T2QZf2GnSG6TtDpDHeRrDMQRqUywGJiTSmNuOxMpdlPWfVSd25hY1vR2xzO8zJo OrdPYdWHHiOcxAxA== Received: (qmail 3856049 invoked from network); 17 Apr 2026 09:42:43 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 17 Apr 2026 09:42:43 +0200 X-UD-Smtp-Session: l3s3148p1@9qIiGKNPQ2NtKXL4 From: Wolfram Sang To: linux-renesas-soc@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Sudeep Holla , Wolfram Sang , Jassi Brar Subject: [PATCH v2 4/4] mailbox: mailbox-test: make data_ready a per-instance variable Date: Fri, 17 Apr 2026 09:42:36 +0200 Message-ID: <20260417074237.16053-5-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260417074237.16053-1-wsa+renesas@sang-engineering.com> References: <20260417074237.16053-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" While not the default case, multiple tests can be run simultaneously. Then, data_ready being a global variable will be overwritten and the per-instance lock will not help. Turn the global variable into a per-instance one to avoid this problem. Fixes: e339c80af95e ("mailbox: mailbox-test: don't rely on rx_buffer conten= t to signal data ready") Signed-off-by: Wolfram Sang --- drivers/mailbox/mailbox-test.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/mailbox-test.c b/drivers/mailbox/mailbox-test.c index ec591616fe46..7b6ef033e77a 100644 --- a/drivers/mailbox/mailbox-test.c +++ b/drivers/mailbox/mailbox-test.c @@ -28,8 +28,6 @@ #define MBOX_HEXDUMP_MAX_LEN (MBOX_HEXDUMP_LINE_LEN * \ (MBOX_MAX_MSG_LEN / MBOX_BYTES_PER_LINE)) =20 -static bool mbox_data_ready; - struct mbox_test_device { struct device *dev; void __iomem *tx_mmio; @@ -42,6 +40,7 @@ struct mbox_test_device { spinlock_t lock; struct mutex mutex; wait_queue_head_t waitq; + bool data_ready; struct fasync_struct *async_queue; struct dentry *root_debugfs_dir; }; @@ -162,7 +161,7 @@ static bool mbox_test_message_data_ready(struct mbox_te= st_device *tdev) unsigned long flags; =20 spin_lock_irqsave(&tdev->lock, flags); - data_ready =3D mbox_data_ready; + data_ready =3D tdev->data_ready; spin_unlock_irqrestore(&tdev->lock, flags); =20 return data_ready; @@ -227,7 +226,7 @@ static ssize_t mbox_test_message_read(struct file *filp= , char __user *userbuf, *(touser + l) =3D '\0'; =20 memset(tdev->rx_buffer, 0, MBOX_MAX_MSG_LEN); - mbox_data_ready =3D false; + tdev->data_ready =3D false; =20 spin_unlock_irqrestore(&tdev->lock, flags); =20 @@ -297,7 +296,7 @@ static void mbox_test_receive_message(struct mbox_clien= t *client, void *message) message, MBOX_MAX_MSG_LEN); memcpy(tdev->rx_buffer, message, MBOX_MAX_MSG_LEN); } - mbox_data_ready =3D true; + tdev->data_ready =3D true; spin_unlock_irqrestore(&tdev->lock, flags); =20 wake_up_interruptible(&tdev->waitq); --=20 2.51.0