From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com [209.85.216.49]) (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 4952A33BBB9 for ; Tue, 7 Jul 2026 08:45:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783413958; cv=none; b=X38Ot3t1RpA5PmpNtNTW6bfMdZpeZpUivEZQpGZEGS8Bhm5hWNM2dOMl+fRzSnfFJ1RHBOlo4bxVTs8Bf8S4kov/KOIDmqJuDsDXQMn6o7jnpTwtkuDJUodWxP9flEF9XSxzcY5vLTJ3GSm4fCL0bWz/pxqOZijoL2dEokf5Yyk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783413958; c=relaxed/simple; bh=db5RJ2tmE6l/dT+o++KtVIbJ/fyYos1+O4TTVJb7K9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bvcq8bkRWaDCfFZhXuIZ6gdGPQ2IJ2l4rnnwWOcRBAVu3oYIHsIUGGXlM6/WuzuY/QwXothvO5MEwPlPB7VPa5X0H5RlrXswq56ElByZuvQP5u68CI9tgS0agWt0dJegc4Fp9mHXt47Y+jSS7cYSDHOpRUVpeRhYwFzAfJL0+4I= 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=iGDo4eqk; arc=none smtp.client-ip=209.85.216.49 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="iGDo4eqk" Received: by mail-pj1-f49.google.com with SMTP id 98e67ed59e1d1-384c94c9414so2130491a91.3 for ; Tue, 07 Jul 2026 01:45:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783413957; x=1784018757; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=b1G/oBUGupjbaXr0RnxijMav+BBz6qUuhO3vayI0gEo=; b=iGDo4eqkAntrkFWriu5OPpGEqp6vMWTOuRqvsAof+naIHbgv+CxKn1MA6HKkgz6cEz S5Xi1fHXwhsmXrtUvPwGbfFwkAqoKZoLSrnJaMMdlEXgH+Lb+gRNBWXubGZtxGhnAZ/M iYq/+6iDY2x1twrwHjmp/wWipmt6WvYbSZUpRoOHpC7nyHdXAbPtQTjHla9tUF/hnMPo /8tD18d3CCSso74gSnoh5dSuquo4vsrpZ045tugcZOmGDplg4x9iw40x72i4VUxLkkAM jw1VEBXGJEHv4WFFpLxBPJlnNL3BeBj2pH8k5aMfpoKEiDZBxhTCDqcb/414g6w3gNoK gEpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783413957; x=1784018757; h=content-transfer-encoding:mime-version:references:in-reply-to :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=b1G/oBUGupjbaXr0RnxijMav+BBz6qUuhO3vayI0gEo=; b=AXk8iUzyAnwwChdShaF431fuC5aHly855b7MZRVdIJRQJXs7qtNHlwu43kn0pscVM7 g9ZWHuw3GJ/hAtriIyyJXVU8DsYVHqazk/UejC3Myivx9I99QJiDmTQevpjxDBsQICQR r1jZ9Y416Fm7v1OrS2TdaulbjhuJamV1x2CS1IPDLXdPXxDZ9tEciNd8UT8wyM2bmDqo X1NgsUMzJRBPcX9kI02CSxb5uWMDydSJO9wRXnoIcooZjRJ8RSDZ5ycSIf23UfHWSKkp 2Rstty/41Z8QSbrjy/xkg2MtN07lMsYZGZ+t4WUCXd3sHkU4UH7fLabseFPsDo4N3voo VUUg== X-Forwarded-Encrypted: i=1; AHgh+RoWUBzT6Atb6PdjG73KmjQa+5Ynb9pg4TORzP8gMkcfi+q/M9xQTVpMPFtGrnTHMJkdYePTNDj6zwkxG/0=@vger.kernel.org X-Gm-Message-State: AOJu0YyXoIYDqtP3ZILUAfMhFBwx6Wrc7VjNDBsf+nnnZf6aDvYpNPWV VYvgPZvCdCNLjJ2yn8ItEPA6lKpJDJP+4r5jgIf79MA7Z6R0Ako/pSqz X-Gm-Gg: AfdE7cmqTOVDaaLPDlM5YZyVqlKSFuVtg8W/OjBNtBOOsMYqzd/YtxSQeetxCWu8RW6 7JJVMYKIgTjp5c1WTW52ImK/EWgvTTiWzCRYgGg/hFSF4G1Y92qc+F/98wy/XWnVI36N1Hia9mX GbZdNC8Bso+j53JFvnFEcD4ic2mZMgEGnsI11q/BJAWRtsAU7Amn9+0lz3UNdyMyc0VqanGFu50 +mTkuhFaQgzIl4XfRMVMVvSPMABzic9Lsk2AAFEO1ultj5+QXQX4m+E0ET47EDdcWIpdEOCd9dw hXCMS8RNsIk7TP7WPTkKxAgrTC9/shB4J2spx6HK6zMf4h+5hdQIdxXh08ki0oswZGzsiaq/P0X gw46VAzCjKVEHutTp77Bb4dJbfHH4E3xUT98Hi9O0cmlY5ysZy+F4s2RkeNWY7aq6ylL/wJQyXF m6ZF6N/XZN4YPaPh+HDpj+WP7sj1+eifh0ipakCR52ZW3ZS4Y= X-Received: by 2002:a17:90b:2712:b0:37e:2505:cde9 with SMTP id 98e67ed59e1d1-38755863957mr3950927a91.13.1783413956659; Tue, 07 Jul 2026 01:45:56 -0700 (PDT) Received: from phuc-desktop.. ([183.91.15.56]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-387d13fd7bfsm717546a91.6.2026.07.07.01.45.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2026 01:45:56 -0700 (PDT) From: phucduc.bui@gmail.com To: Cezary Rojewski , Jaroslav Kysela , Takashi Iwai , cassiogabrielcontato@gmail.com Cc: Kees Cook , Dan Carpenter , Cen Zhang , Len Bao , Mehul Rao , Sebastian Andrzej Siewior , linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, bui duc phuc Subject: [PATCH v2 6/6] ALSA: pcm: Return -ENODEV instead of -EFAULT in snd_pcm_open() Date: Tue, 7 Jul 2026 15:45:06 +0700 Message-ID: <20260707084506.718583-7-phucduc.bui@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260707084506.718583-1-phucduc.bui@gmail.com> References: <20260707084506.718583-1-phucduc.bui@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: bui duc phuc When try_module_get() fails in snd_pcm_open(), the owning module is going away and the device is no longer usable, so -EFAULT ("bad address") is the wrong error. Return -ENODEV, matching the other unavailable-device paths in this function(the NULL pcm check and the card->shutdown check). This changes the errno reported to userspace on this rare race. No other behaviour changes. Signed-off-by: bui duc phuc --- sound/core/pcm_native.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 3462cd5275a2..4fe5fab8d096 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -2913,7 +2913,7 @@ static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) if (err < 0) goto __error1; if (!try_module_get(pcm->card->module)) { - err = -EFAULT; + err = -ENODEV; goto __error2; } init_waitqueue_entry(&wait, current); -- 2.43.0