From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 D304A518145; Thu, 17 Sep 2026 16:59:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664376; cv=none; b=PYhPruJWKiwJpMpR/Yz//fUyXwSrTdgehOvuPcnzdma36hWcmJxwp/UgTcEVMA31nBnvP3yDwe8+Pi/T/IKQZZaTAn3S8cqLLZoHKpV9tOjdfcboGqFyc+0niBAIKBMtDHes28Ezkq1KHKjPgLxAz2GxflfkGjg41WbJZZfRVjo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664376; c=relaxed/simple; bh=qH+jFssgf59bgo7Bo3mn+U5a/0BGFTkStwb+U79hzxU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bn5W2AdXeEWpUcdj6GIIvz3kV4wJ7oR/1KLvuH944jg07ZXyeKWW9p/VBPhvCzjZsKuE77K/nKkOb+pVFwdS2lK0ysrTa+9KVGZSuqllqTmXs+fxpoP0FAYPbUosmO25XCFq4kGNChmbFjnYqKZ2Fxlx6OtZ/rpdQ/HxjxshywI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TyhWg3CQ; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TyhWg3CQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E2761F000FF; Thu, 17 Sep 2026 16:59:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789664374; bh=AxDkiG5QxVaF2rHDOpXITpRutzkf3CC/yC0oZQ5VU1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TyhWg3CQguQHxHC9e6f7GSgzLUn4oF/NCJ9d8iGNq/c+f5RKnimxtQ/8lHFRNe75K jz4fVA5TFGtftpxX0AHxxSoQIZwdf5Tq0pbt0X6De2ROVNx3lsx59dou/c7AxvODDa kwIQ4Ge1MNvzQPl2CcRsi2XN8L922+USyr8hz1LE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tuo Li , Mark Brown , Sasha Levin Subject: [PATCH 6.18 0352/1250] ASoC: mediatek: mt8365-afe-pcm: fix possible NULL-pointer dereferences in mt8365_afe_suspend() Date: Thu, 17 Sep 2026 16:02:27 +0100 Message-ID: <20260917151601.609639784@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tuo Li [ Upstream commit b8948ac26efc395264a47f9a743889065adb5cff ] mt8365_afe_suspend() allocates the register backup buffer with devm_kcalloc(), but does not check for allocation failure before using the returned pointer. This may lead to a NULL pointer dereference when accessing afe->reg_back_up[i]. Add the missing NULL check and return -ENOMEM on allocation failure after disabling the main clock. Also propagate the return value of mt8365_afe_suspend() in mt8365_afe_dev_runtime_suspend() so that the suspended state is not updated when suspend fails. Signed-off-by: Tuo Li Link: https://patch.msgid.link/20260528064107.470824-1-islituo@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c index d48252cd96ac4..bf92c8922c236 100644 --- a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c +++ b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c @@ -1975,10 +1975,15 @@ static int mt8365_afe_suspend(struct device *dev) mt8365_afe_enable_main_clk(afe); - if (!afe->reg_back_up) + if (!afe->reg_back_up) { afe->reg_back_up = devm_kcalloc(dev, afe->reg_back_up_list_num, sizeof(unsigned int), GFP_KERNEL); + if (!afe->reg_back_up) { + mt8365_afe_disable_main_clk(afe); + return -ENOMEM; + } + } for (i = 0; i < afe->reg_back_up_list_num; i++) regmap_read(regmap, afe->reg_back_up_list[i], @@ -2012,11 +2017,15 @@ static int mt8365_afe_resume(struct device *dev) static int mt8365_afe_dev_runtime_suspend(struct device *dev) { struct mtk_base_afe *afe = dev_get_drvdata(dev); + int ret; if (pm_runtime_status_suspended(dev) || afe->suspended) return 0; - mt8365_afe_suspend(dev); + ret = mt8365_afe_suspend(dev); + if (ret) + return ret; + afe->suspended = true; return 0; } -- 2.53.0