From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 67B3733993; Thu, 15 Jan 2026 17:08:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768496932; cv=none; b=oquA1HTC0bwaFfcnqrQzlPW1exIFV5zUolAoKAP3wp46T3+Wpp1juR+zK16oX0oYpbqPhRmCVzwJiQJxXw71QzNeM+Y5fEPq2aoFUz4x+VqHH3NsIsGuDb1pXWwE2OZsOR/AYgk72I5IeZ2uHMPDuYTS1V0/+GE3nxYMFhHQZ2c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768496932; c=relaxed/simple; bh=94XlK6m+aiOoHzukg3SVxLxruAUiydf/dZ9vLQyt5ak=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TzxolZAAQkEduhXM/EriMPbza/OLK8qlfrUFw9KVly1jn4YDcexOdV2I+UIjGN3z+e1C50d+1AZ/XFjZaZgEyKybrPI3koeoscTxgfY7L1LuciILrM/2xR8j31Ez8zt5BgDOEQGx343ryycMadqfzGs7jhFV/oDhAlWsEruxpV0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ijkTyxfy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ijkTyxfy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E5D61C116D0; Thu, 15 Jan 2026 17:08:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768496932; bh=94XlK6m+aiOoHzukg3SVxLxruAUiydf/dZ9vLQyt5ak=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ijkTyxfyIWfc7K46B2VfjsfVyqJbE1bGFRorhVUzOmN60sZIBsgBZSIs2DM81Shxv L2l0zT/+HRVl5B7X9ddTVj3QRvkhWj/0QcICRLBNSH0cG/YeB1IU0rguxra2fa8SI5 Us/oqINbYsbWWFV1PkGb2aMjX1hkeOn8YcwwtefM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Takashi Iwai , Sasha Levin Subject: [PATCH 6.6 66/88] ALSA: ac97bus: Use guard() for mutex locks Date: Thu, 15 Jan 2026 17:48:49 +0100 Message-ID: <20260115164148.698812705@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164146.312481509@linuxfoundation.org> References: <20260115164146.312481509@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai [ Upstream commit c07824a14d99c10edd4ec4c389d219af336ecf20 ] Replace the manual mutex lock/unlock pairs with guard() for code simplification. Only code refactoring, and no behavior change. Signed-off-by: Takashi Iwai Link: https://patch.msgid.link/20250829151335.7342-18-tiwai@suse.de Stable-dep-of: 830988b6cf19 ("ALSA: ac97: fix a double free in snd_ac97_controller_register()") Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- sound/ac97/bus.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) --- a/sound/ac97/bus.c +++ b/sound/ac97/bus.c @@ -242,10 +242,9 @@ static ssize_t cold_reset_store(struct d { struct ac97_controller *ac97_ctrl; - mutex_lock(&ac97_controllers_mutex); + guard(mutex)(&ac97_controllers_mutex); ac97_ctrl = to_ac97_controller(dev); ac97_ctrl->ops->reset(ac97_ctrl); - mutex_unlock(&ac97_controllers_mutex); return len; } static DEVICE_ATTR_WO(cold_reset); @@ -259,10 +258,9 @@ static ssize_t warm_reset_store(struct d if (!dev) return -ENODEV; - mutex_lock(&ac97_controllers_mutex); + guard(mutex)(&ac97_controllers_mutex); ac97_ctrl = to_ac97_controller(dev); ac97_ctrl->ops->warm_reset(ac97_ctrl); - mutex_unlock(&ac97_controllers_mutex); return len; } static DEVICE_ATTR_WO(warm_reset); @@ -285,10 +283,10 @@ static const struct attribute_group *ac9 static void ac97_del_adapter(struct ac97_controller *ac97_ctrl) { - mutex_lock(&ac97_controllers_mutex); - ac97_ctrl_codecs_unregister(ac97_ctrl); - list_del(&ac97_ctrl->controllers); - mutex_unlock(&ac97_controllers_mutex); + scoped_guard(mutex, &ac97_controllers_mutex) { + ac97_ctrl_codecs_unregister(ac97_ctrl); + list_del(&ac97_ctrl->controllers); + } device_unregister(&ac97_ctrl->adap); } @@ -312,7 +310,7 @@ static int ac97_add_adapter(struct ac97_ { int ret; - mutex_lock(&ac97_controllers_mutex); + guard(mutex)(&ac97_controllers_mutex); ret = idr_alloc(&ac97_adapter_idr, ac97_ctrl, 0, 0, GFP_KERNEL); ac97_ctrl->nr = ret; if (ret >= 0) { @@ -323,13 +321,11 @@ static int ac97_add_adapter(struct ac97_ if (ret) put_device(&ac97_ctrl->adap); } - if (!ret) + if (!ret) { list_add(&ac97_ctrl->controllers, &ac97_controllers); - mutex_unlock(&ac97_controllers_mutex); - - if (!ret) dev_dbg(&ac97_ctrl->adap, "adapter registered by %s\n", dev_name(ac97_ctrl->parent)); + } return ret; }