From nobody Sat Jul 25 22:33:40 2026 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 2AD7B4502F; Mon, 13 Jul 2026 02:04:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783908279; cv=none; b=O+p/ZSqicgWb+3wkDv3MQo6bFYwuSuH7Bf07GO6BIAdHvWUPxKGZnWarm8rvwKUEGtb46c47PvRBTfxSjz/mrDUUyYyFI1WKvkcZKRzovt94WUdrTNuci5YRPHgbcZ8vlDDxqlQUGWx6OKHTdKAhAt1s1WqaVxdjiNtY30WLGj4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783908279; c=relaxed/simple; bh=cWU7sRSGVyVIgf9FQ/Pf08rfSuCqL/YOzbcs4nwweZk=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=G7NhXLoKjXNVfvP4hZzyciClgKdQ0GQDK2Xfs2AwLyAkhESHCK0qrqhRrK8lkNKN+TthhU/9Qz/dNK/96Ymns8viHezHWAB0DS+UcCRINYRBLmZacabhoUJQdVhoeuL1tm/+Tm5QUFc2vh9hbEMWBwN4SGrx8F2omjepOXUHIpU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 301ac06a7e5f11f1aa26b74ffac11d73-20260713 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.12,REQID:8d88ba67-c07d-4a0a-9a6b-9cf7bf6a9b14,IP:0,U RL:0,TC:0,Content:0,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:25 X-CID-META: VersionHash:e7bac3a,CLOUDID:4df0c16c72fde11498a057c3491b9874,BulkI D:nil,BulkQuantity:0,Recheck:0,SF:102|136|850|865|898,TC:nil,Content:0|15| 50,EDM:5,IP:nil,URL:0,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0, OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: 301ac06a7e5f11f1aa26b74ffac11d73-20260713 X-User: songxiebing@kylinos.cn Received: from localhost.localdomain [(10.44.16.150)] by mailgw.kylinos.cn (envelope-from ) (Generic MTA with TLSv1.3 TLS_AES_256_GCM_SHA384 256/256) with ESMTP id 237048547; Mon, 13 Jul 2026 10:04:31 +0800 From: songxiebing To: tiwai@suse.com, perex@perex.cz Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, songxiebing@kylinos.cn Subject: [PATCH] ALSA: hda: Check snd_hda_power_pm construct error before executing verb Date: Mon, 13 Jul 2026 10:04:27 +0800 Message-Id: <20260713020427.300628-1-songxiebing@kylinos.cn> X-Mailer: git-send-email 2.25.1 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" From: Bob Song When userspace writes 1 to /sys/bus/pci/devices/XX/remove to remove HDA PCI= device, the codec device enters runtime suspended state early. The snd_hda_power_pm= RAII constructor fails to wake up codec, but the original code ignores pm.err an= d continues to execute hda verb commands. After pci driver remove callback completes, d= evres automatically iounmap the BAR virtual address bus->remap_addr, resulting in= access to invalid unmapped MMIO address and triggering page fault BUG. Add error check for snd_hda_power_pm constructor result: 1. Detect pm construction failure when HDA core device is suspended; 2. Print warning log with command and error code for debug; 3. Return early to skip subsequent hardware register access, avoid page fau= lt crash. Signed-off-by: Bob Song --- sound/hda/common/codec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/hda/common/codec.c b/sound/hda/common/codec.c index ef533770179b..69ddd153509c 100644 --- a/sound/hda/common/codec.c +++ b/sound/hda/common/codec.c @@ -39,6 +39,12 @@ static int call_exec_verb(struct hda_bus *bus, struct hd= a_codec *codec, int err; =20 CLASS(snd_hda_power_pm, pm)(codec); + if (pm.err < 0 && pm_runtime_status_suspended(bus->core.dev)) { + codec_warn(codec, + "Failed to send cmd 0x%x ret=3D[%d], hda control device is suspended= \n", + cmd, pm.err); + return pm.err; + } guard(mutex)(&bus->core.cmd_mutex); if (flags & HDA_RW_NO_RESPONSE_FALLBACK) bus->no_response_fallback =3D 1; --=20 2.25.1