From nobody Mon Jun 8 06:36:11 2026 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) (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 D0E612F4A18 for ; Sat, 6 Jun 2026 04:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780718836; cv=none; b=D9naeNkW4lYGgDxo+comdXr2/MFTNywSbqgZJ1wiJfXaxJ9yF73Fz24dnDIKJYhutz7q5BZ01RUf+mM7Bp7wwO+xZrFUuPYngSlkdtP734C7jrDg3uyVmBBeJmVwhkqYHaAMniVQU5gm7C3nWtNm7bMyap5TBHBU/qMz/R4g9VU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780718836; c=relaxed/simple; bh=w8hHiCqTiBueu+hLKwHEFRoEYFKueC7agAu4x975W9w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=cEmj56D59djm/INf9I/J8RqwCwl4lp5WN0eRVpuk1l6Ikg4MJpYYqEo8z+pIaHJylwU9HJqoSBCPS4SI/VA1AP9J1Fy+KUpp5EipfKC72+dd68pnDYyDbUFo5KjyaT6ksVpOTiLHHycS30ql4PDGlURZlN6ikIoHmX3WynO++yA= 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=ZQhSeOYy; arc=none smtp.client-ip=209.85.214.174 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="ZQhSeOYy" Received: by mail-pl1-f174.google.com with SMTP id d9443c01a7336-2c0c2d8b95bso17580155ad.1 for ; Fri, 05 Jun 2026 21:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780718835; x=1781323635; 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; bh=1rjS832aE1oA+NWR2plR5pJJ8WRs2Vb19cfZDQa4g2Y=; b=ZQhSeOYy+RSGlSjG1Hfc5sztL0CsNfqB1cIu73Ymzx/UU4z8ROh1RmlLyDaCRAc8Vg s+DiBBQcdTmD7rxvZCoBI3/hsR7+v1CRqfqdMBeC9dO2VUN9Azy+jmsik9IeMUtYZITp YM7BEZF1XRpmZ50u5PO/whJP7BYpxyu4R6BeuOcsBt5d/oW4v3eHOxS+N06kQGI7K1Ht 9P0pr+3yEhJ33Ia0iCZ1Q1Z7K77jhe+kVEbdOpOWycVJgl0zR+/2MkX/XfpvgbLMmOpn SOoNPvctklj10O47/Ts9Ody6FY5/V5kNom1aGhU0DeRKjfWrYFmeDYO/HaZAa7uRA91J JDlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780718835; x=1781323635; 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; bh=1rjS832aE1oA+NWR2plR5pJJ8WRs2Vb19cfZDQa4g2Y=; b=bwGiq3PNVZSlJOUJszRqrFRj7/8E/t5tF673jVLEM4ip1rqFmOaFvYOwagFvWksTLB bLL+3+RxwQEfYKWLiAe4sUMToNzkJvhil5N/HQJKg11VeCjTUZmC8mileVdmdbMLoXhL jiRE7ZX8Ouw+P6BCeBcTqAfFimXGL4k4Ej0h+Aux9E9ng87Ls0KdZw1nXqhIZipzSCk4 Sea23AOmUyaMlksd5GvndDFdkvJKOICY/F6IWYDPQ6QADFwwk2MIG3VhJNQuhdqi3kQ9 gvN7D5p/JGPeEhZHGyafBFTM0wHBPFld+rPjohmyBVOTCFDSr8btlUP8W1FpZWnHKcI0 W2Cw== X-Forwarded-Encrypted: i=1; AFNElJ/ObZ+gRukOGrqJUfwLpDCu5Oeb2jLa5YEneBy6gXlnZxM2gdVzHr+uivGxYT8ADGBQcOiQW1KJ0GdyjQw=@vger.kernel.org X-Gm-Message-State: AOJu0Yz6fpjFhmM+AJk7hPLRl3qZ99RWH/mhFfxCG24JSB/2wQLiVL6l 485bkq6yevRNkal0wDncNZSssI2KPKAOxAdKB95t1m3KW5/61sbYGGsc X-Gm-Gg: Acq92OENhzgYtXHWB3Mw3j58iS898irPrAy2uRLDsq8bGz2GHJ96OtpTKRH4T3SeMGK ufNyRSuHwfpqAnfOZrYg0XCCfIyEwp/9tZcSOqQifnljZ3DF3chF3fYM7ic5nj4WgRM9x7OfPaD JQ8jNFubGfY6k/iThNk/ZEPMyUi6/21/DwlEqYHJL4PJGhTjVFIjrc9T9Q7jkfGCG0tFZCsyUU2 clNukAWDnMKnX/Z1tcZtDWSAjA+SQschedIzuAy22xbYWsnqy3t7Y4JNMsFO6XuquYAdIUlYWiC Q2rmOXHgn3auh5StVEKDFiSCdsSkWQLYl/+oTVKshgv03zp1VVIJnGxuw9qyxVcaeiSTETUFmfF +pzMBLsrDeIBzAQEaQanLlmCDuMNWzjoY+dfFktG4yHfy8tIf/jcdaa3CbnSar2ViQNDJPQ1Y/5 yjI0QJ97dhbTkvxz3p6M/K+kCCvxEHL6T3kH2NJJEZAs14nU/E3TlaVA== X-Received: by 2002:a17:902:e78f:b0:2c0:a373:89bf with SMTP id d9443c01a7336-2c1e80f9975mr70654185ad.1.1780718835009; Fri, 05 Jun 2026 21:07:15 -0700 (PDT) Received: from haichao.tail057a43.ts.net ([2001:da8:e000:1206:967f:7ce4:ec98:f08b]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c164f84335sm107056905ad.19.2026.06.05.21.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jun 2026 21:07:14 -0700 (PDT) From: Ruoyu Wang To: Liam Girdwood Cc: Mark Brown , Jaroslav Kysela , Takashi Iwai , Matthias Brugger , AngeloGioacchino Del Regno , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Ruoyu Wang Subject: [PATCH] ASoC: mediatek: mt8365: check suspend backup allocation Date: Sat, 6 Jun 2026 12:07:08 +0800 Message-ID: <20260606040708.13-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: quoted-printable Content-Type: text/plain; charset="utf-8" mt8365_afe_suspend() lazily allocates the register backup array and then stores register values into it. If devm_kcalloc() fails, the suspend path dereferences afe->reg_back_up in the backup loop. Check the allocation result before using the array. Disable the main clock before returning so the error path balances the clock enable at the start of suspend. Signed-off-by: Ruoyu Wang --- sound/soc/mediatek/mt8365/mt8365-afe-pcm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c b/sound/soc/mediate= k/mt8365/mt8365-afe-pcm.c index d01793394f225..74e4f53b31605 100644 --- a/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c +++ b/sound/soc/mediatek/mt8365/mt8365-afe-pcm.c @@ -1978,6 +1978,10 @@ static int mt8365_afe_suspend(struct device *dev) afe->reg_back_up =3D 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; + } =20 for (i =3D 0; i < afe->reg_back_up_list_num; i++) regmap_read(regmap, afe->reg_back_up_list[i], --=20 2.34.1