From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A5DE3BA236 for ; Thu, 9 Jul 2026 06:23:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.178 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783578184; cv=none; b=OElKwAI+F1NliIeTqj0F2fDIEUHLoG/CHA5rYoZKLLPIYoNPaZa+Quw8PH5nzWmDogOuIiO1UR1ovFnwslJ97mhRqZQG0GfSQWhUmDkN8ens5MUJ1AoFVkQwrpPrsn3Sdjvjb6mrF+5zAnu5k8eljZZXmyDgQzmXnBhv7lSJGaQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783578184; c=relaxed/simple; bh=sANAXs2Kl7YWqrmcA04fGVcJp/Ys+yfJ2HhKOPKUAIs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=qAc3iJSj5r/910ZueEFsXYMOj4rQG4K4sOBiIycNhr8LNS7FY/4zClBQs7wV19M+H1bW0rKN6hgQz3W1cL7wSrAKn5rebWRDg7QzTwj1M5pUMC+uTN+vXcSCw2YvMvqaCz5h6cMJesjh5oOU+91Z3VRyoJ5yHtvItckVbxqGFgs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=myhYQo1Y; arc=none smtp.client-ip=209.85.215.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="myhYQo1Y" Received: by mail-pg1-f178.google.com with SMTP id 41be03b00d2f7-c9d1fc053e0so1163739a12.1 for ; Wed, 08 Jul 2026 23:23:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783578183; x=1784182983; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=4ntJpwww9AG144NhiF2fIApoT06Qh+39umHvBh4GnFU=; b=myhYQo1YSSbVKmRclCim9OBOh4xfjHEQOt/fCv+/xMYfDuF+RuU5TfoklVII/c1nOp MVemTHUerSnQQ17MIiQglOYeMO4M1XbdbunRRc9uwTxt26keUq1BMoVsDghEX7j0+9MW MhdWzG/CGuo3IScEhEkuekon4BhyR06TVzLm1K0uFnyQSYkZUY+FarlAh91zKLa3LCQJ iiXy4Cz1sFxTT+Me+PZO/zyT3fjL6Oh89FZ2SYnVYnp8LGdLgD/5GIioHtDRp5QJfzQE cpAU2339/S75vndSrthTQJ1OZGMrMEeQjk+LvXoTYh506J+SLRghl6hJxsndQxzXbRFV PtXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783578183; x=1784182983; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4ntJpwww9AG144NhiF2fIApoT06Qh+39umHvBh4GnFU=; b=CnQWnGlk0o2kC1StjFs1af29LWWwBZ0lDCwoABAo3vDeytqjtYZJiaKSnshiOQ34vU hXVydU10HXQJQdVddzL5NdeI1gx/6dJKlZXdtY8wfDyN/OTiTwEvPJGSLKffI8E6f632 MIxjRSMYaw5VjCAbQPDNTdYVU6/OxulCT+JXAoxdOtZTBy3Vk/o/ATdrV/8UAn20wkPX Io8ju0pznyWmA2W6cRHSHWPt/vm38dXsjPdZPv/arzhwYAM6G3AnTmYZxjuSkoGwJR1m YejebpN+Tcnwg6gPUeZPIf3oEmga97Nm6vWFZqc3kSBbwEpUzCWXwbGBZXiENjFj5vSi 4kAA== X-Forwarded-Encrypted: i=1; AHgh+RrT83xPKUQ0CSOCfBE6TWkoZMQ40eM1VoJ8OJKldPkQ9IPGvGUMTsY3supaGuOtMivsU3cdHTaou+pGvUQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxqYPhWA31HJz/+fniQFy14Gy02FbfAmGLZplcn2qxAPvmMt5jH AxTJ6iKBwUKR64q7VIgfu95PTXg52GmCVsMg8Cy8qe1Rz30qM2c1Y3eO X-Gm-Gg: AfdE7cndPwjOHHYFeVTcSLSyObUmILT3E9FVQbIPKUO7Yi03FP/s/1L9UFFevr8jMOu GXxqfkiEBzg+wjdfocSwePiHsTYKKnfuFvc/NWFZhomuQe4fCAOgKWKeN1rvg2FqI4bBTTnVn5E EICdoj3QInWMKg4SMG/AO9zVRT1kUf4H8dDAnW1e4wfpaUpJ8GL515oKNMTka9R6fwOkHOaG1zI UvRGeRvZqmTTOWJZbr4igVPS8ThALNVLYO7rSg0dqh62+4U6JY25o5cq790sL1xMKWXXuiP+b3R syolL8btPROOnSNJFqm+f2jOu6z6DiHRmFVylF+y3YzZrWkl9uO0TkVzlW9NHKc4CBStGA71b6K dsr4HXPaqiGWX0248R3jTg9fJ8dr8AmLeEurEDWudnjGmrxvi4wfBK/Vg7OWiPP+R6M9ZePpgHp mzNLHAk+3s8nhsSZvjRXvelC0E6BVNn1/aRoBgY5eE3hk= X-Received: by 2002:a05:6a21:4591:b0:3bf:95f4:dad7 with SMTP id adf61e73a8af0-3c0bd1aba77mr6910775637.41.1783578182556; Wed, 08 Jul 2026 23:23:02 -0700 (PDT) Received: from haichao.tail057a43.ts.net ([2001:da8:e000:1206:ea9b:46f2:6d0c:46c7]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ca5b3a2e42bsm3298012a12.30.2026.07.08.23.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2026 23:23:02 -0700 (PDT) From: Ruoyu Wang To: ogabbay@kernel.org, quic_jhugo@quicinc.com, joro@8bytes.org Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, Ruoyu Wang Subject: [PATCH] accel/amdxdna: Clear mailbox channel after create failure Date: Thu, 9 Jul 2026 14:22:56 +0800 Message-ID: <20260709062256.4166833-1-ruoyuw560@gmail.com> X-Mailer: git-send-email 2.51.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit aie2_create_context() stores the allocated mailbox channel in hwctx->priv->mbox_chann before starting the channel. If xdna_mailbox_start_channel() fails, the error path frees the channel but leaves the saved pointer intact. A later context cleanup only checks whether hwctx->priv->mbox_chann is NULL before stopping and freeing it. Leaving the freed channel pointer there can therefore make cleanup operate on stale memory. Clear hwctx->priv->mbox_chann after freeing the channel on the create failure path so later cleanup sees that no mailbox channel is owned. A static analysis checker reported the stale ownership state, and manual source review confirmed the error path. Fixes: d5b8b0347fa8 ("accel/amdxdna: Split mailbox channel create function") Signed-off-by: Ruoyu Wang --- drivers/accel/amdxdna/aie2_message.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/accel/amdxdna/aie2_message.c b/drivers/accel/amdxdna/aie2_message.c index c4b364801cc04..a22d025794598 100644 --- a/drivers/accel/amdxdna/aie2_message.c +++ b/drivers/accel/amdxdna/aie2_message.c @@ -277,6 +277,7 @@ int aie2_create_context(struct amdxdna_dev_hdl *ndev, struct amdxdna_hwctx *hwct free_channel: xdna_mailbox_free_channel(hwctx->priv->mbox_chann); + hwctx->priv->mbox_chann = NULL; del_ctx_req: aie2_destroy_context_req(ndev, hwctx->fw_ctx_id); return ret; -- 2.51.0