Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3386378lkq; Mon, 23 Nov 2020 04:30:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwCIvx0n8nu5Tn9zGgTojq/rCv7eHS73aIUr7qTa71Q414LV1RdlzFxk6pf72P9ig4Uy3bl X-Received: by 2002:a17:906:5fd9:: with SMTP id k25mr16479624ejv.539.1606134659207; Mon, 23 Nov 2020 04:30:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134659; cv=none; d=google.com; s=arc-20160816; b=ND4ovTIarw5B6gUn8nySoon/aUmi62YcjCHA2zXnGUM35B46YoDnC4LcfgmsKoNUYM 2Pbcn1EY4aNKnadwYgZC05AcTR5PuypBVZiCqep+ZEyR8zRxlstdwJNzWTHiBTn7YKO8 J+0TGVzL4Xkd5igj9XZpPYiIo6lhZaYPHPgBaeov3Rk0HPN9Z6z/vlDsJgGuqK5XoNE2 xRWmAXye/aFtL8aUZRQFJ7zcAXMx4vuVqC+p3cd3Z6fzX4um6R5gcyHXz4snpK7lICnS VHs38A1prI6j0xyX9TwPTglPK4jqYtTZk8pbLexV1Inq1yrKZxnSq0D5RCa6K59zJW2P 8SZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dG6lKNMk+7EJJ15RqpGwsbcxS/4r55/u+7NHc4trwCQ=; b=f626ORwIcYXYSQnbKWGaEDg5i/hLptbqfGZNt69C+J7RuFAz2YD2gZ8toZl0LF07Fx lS/qk6XRFcRI/OVFBn+r/WjTGZSoRWiLhfF59qtSADWeNU07j2KYJ6zscRSvm3qCEezT mUWFO1DzgzdOOR73qjOPJKUuqkn5DPW62xP7VazoKrbhmNz+jsmQ7H6gFbmozyOGrWxX mbzbXl7CmZN7k0ufeW/khtVpqgE3TsToscOZLgL3XfGjnkLPOyzOz6r+/7rydyqQ2aKX 62as6PjYBGjyokwBST0r2qHx1Op0RRIgPn78Hu+0FKIU12kLvULrZlPsRbU++3J87GLa izKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hu31+keg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r19si6568061edp.550.2020.11.23.04.30.36; Mon, 23 Nov 2020 04:30:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hu31+keg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730067AbgKWMZz (ORCPT + 99 others); Mon, 23 Nov 2020 07:25:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:35312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730029AbgKWMZl (ORCPT ); Mon, 23 Nov 2020 07:25:41 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id DB70520857; Mon, 23 Nov 2020 12:25:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134340; bh=YoQDnUTsqVY+WKspD6+ZqPA26Klmis3QpVjN5O9GZjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hu31+kegdXVDR6AU4vE0AlCXWpASJjCepSzoTvVuzcTk1v9AyBCC4xzizK5D72Wu8 hFR1lL3V1uagM6hLXVTA3Gc7086/Wx+Pm8FNj3KHthBDxInwSl7zevj8MZAq9iHdkm ghqGJVqLpZNAPr8Gw7xvsrQGWvtRWtlLhqMpfkvY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Takashi Iwai Subject: [PATCH 4.9 36/47] ALSA: mixart: Fix mutex deadlock Date: Mon, 23 Nov 2020 13:22:22 +0100 Message-Id: <20201123121807.301191486@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121805.530891002@linuxfoundation.org> References: <20201123121805.530891002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit d21b96c8ed2aea7e6b7bf4735e1d2503cfbf4072 upstream. The code change for switching to non-atomic mode brought the unexpected mutex deadlock in get_msg(). It converted the spinlock with the existing mutex, but there were calls with the already holding the mutex. Since the only place that needs the extra lock is the code path from snd_mixart_send_msg(), remove the mutex lock in get_msg() and apply in the caller side for fixing the mutex deadlock. Fixes: 8d3a8b5cb57d ("ALSA: mixart: Use nonatomic PCM ops") Reported-by: Dan Carpenter Cc: Link: https://lore.kernel.org/r/20201119121440.18945-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/mixart/mixart_core.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/sound/pci/mixart/mixart_core.c +++ b/sound/pci/mixart/mixart_core.c @@ -83,7 +83,6 @@ static int get_msg(struct mixart_mgr *mg unsigned int i; #endif - mutex_lock(&mgr->msg_lock); err = 0; /* copy message descriptor from miXart to driver */ @@ -132,8 +131,6 @@ static int get_msg(struct mixart_mgr *mg writel_be(headptr, MIXART_MEM(mgr, MSG_OUTBOUND_FREE_HEAD)); _clean_exit: - mutex_unlock(&mgr->msg_lock); - return err; } @@ -271,7 +268,9 @@ int snd_mixart_send_msg(struct mixart_mg resp.data = resp_data; resp.size = max_resp_size; + mutex_lock(&mgr->msg_lock); err = get_msg(mgr, &resp, msg_frame); + mutex_unlock(&mgr->msg_lock); if( request->message_id != resp.message_id ) dev_err(&mgr->pci->dev, "RESPONSE ERROR!\n");