From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.101 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796286837; b=1goUtF5QKp+ygGKYyT+IzomnE4UVSLNOikADeVdFL4U/nYIkqT69fMcJZo/DxwYsHR21 yg7y4AWVKyl6YFq5+FYfvmbVlDQDROLyIMeu4+Lbhkj6sNGlY5iuFjNMUje6hJhn9FyNh /2pXRs/DcQ1FUlBlii68jdzBCCtyyoalq25ntRUIozOJzMc03R8r2ztV7AKtDM5jfC4jN 2WEcU63Rcf0app27mBlMn4JYJQA+M/uOLI8n2jeClPvd2Oxug5XDTmpAmBxRT+6dCJvFv L7QDackxVx1/SlSqVlN1pRzRMT4qrvsZptA3Puue73CpDcyECrTfD41XsMXLNUqPRkg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796286837; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:From:To:Cc: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding; bh=v8aX9yJ73BUp5HjYAgtTHLMPNrYYycmNsRDc5L9gOa4=; b=XCNDrT2o9xgR/J028ZwuoG2cI8jXXEE/TodQeMJgWe0YU1ceXiHFrN44pGWqddmpNP14 XWSzFRyd5gmWgI3cY2EijkgokITjMg6Wg+eodIKuazVwQ0HQS8W0KD5c29mfJylBrFfHd ZBdX47y+j9K6wlsu9VZd71bO/ES9zP0EIoOCNhfYKlf/3sukY9RuGpkkJjVKJEwYrpVtv hrGUqj9VN6BNpDeysTpUz4r/JxnPzSZuu3ItlEMQOoPGPaetbV/KTBZnC1olBs9T9SLFo bKH0cDrrVAQT7PFVtWfXdh0VN/8PhaQZwZGTjlbWWzUWrYlObd699lbbvNruxYefSSw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b="gE3/fkon"; arc=none smtp.remote-ip=115.124.30.101 Received: from out30-101.freemail.mail.aliyun.com (out30-101.freemail.mail.aliyun.com [115.124.30.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBC59606A332; Thu, 3 Dec 2026 08:33:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BBC59606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=gE3/fkon DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796286826; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=v8aX9yJ73BUp5HjYAgtTHLMPNrYYycmNsRDc5L9gOa4=; b=gE3/fkonAChWXFPPmn818i6HDot3iDAn6Bjh9JXeiXJCM2BKc5YlKuqZR81sNIHrNXwCjoFRxysPWGsWhsi8gpQVOAI5l8sYKnQU7LXZa+cTEvU9kc87JqkbXCtPLBywEwGMFBH9x2MpptcziN7QoXZMndiM1hUFX3bQdk2Hkm4= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R201e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033071064103;MF=jiangtianfeng@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0XGDVose_1796286824; Received: from h68d07384.sqa.eu95.tbsite.net(mailfrom:jiangtianfeng@linux.alibaba.com fp:SMTPD_---0XGDVose_1796286824 cluster:ay36) by smtp.aliyun-inc.com; Thu, 03 Dec 2026 16:33:45 +0800 From: Jiangtian Feng To: jassisinghbrar@gmail.com Cc: thierry.reding@kernel.org, jonathanh@nvidia.com, linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org, Jiangtian Feng Subject: [PATCH 1/2] mailbox: tegra-hsp: Reject duplicate doorbell clients Date: Thu, 3 Dec 2026 16:33:29 +0800 Message-ID: <20261203083330.3300442-2-jiangtianfeng@linux.alibaba.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261203083330.3300442-1-jiangtianfeng@linux.alibaba.com> References: <20261203083330.3300442-1-jiangtianfeng@linux.alibaba.com> X-Mailing-List: linux-tegra@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit tegra_hsp_db_xlate() overwrites db->channel.chan for each request. A second client for the same master can replace an active binding, leaving the original client with corrupted IRQ state and allowing callbacks before the new client is installed. Reject requests while the doorbell has a live client. Checking chan->cl rather than the channel pointer alone preserves retries after a failed startup while keeping exclusive ownership during normal use. Qoder, an AI coding assistant, helped analyze the duplicate-binding failure mode and draft this change and description. The submitter reviewed the change and is responsible for final validation. Fixes: 0fe88461a0ec ("mailbox: Add Tegra HSP driver") Signed-off-by: Jiangtian Feng --- drivers/mailbox/tegra-hsp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c index 1f6215c7e498..b1ea2beeaf8b 100644 --- a/drivers/mailbox/tegra-hsp.c +++ b/drivers/mailbox/tegra-hsp.c @@ -608,6 +608,12 @@ static struct mbox_chan *tegra_hsp_db_xlate(struct mbox_controller *mbox, spin_lock_irqsave(&hsp->lock, flags); + /* A failed startup has no live client and may be retried. */ + if (channel->chan && channel->chan->cl) { + spin_unlock_irqrestore(&hsp->lock, flags); + return ERR_PTR(-EBUSY); + } + for (i = 0; i < mbox->num_chans; i++) { chan = &mbox->chans[i]; if (!chan->con_priv) { -- 2.47.3