Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1312842pxu; Mon, 23 Nov 2020 18:05:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3NiLXS8hAhaK4QZe9pxR6ANUhFPHIXDrExn6ti5Uu+FJJMokSNfVTEnsyHPVJNqgeScss X-Received: by 2002:a17:906:af0a:: with SMTP id lx10mr2333503ejb.75.1606183533775; Mon, 23 Nov 2020 18:05:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606183533; cv=none; d=google.com; s=arc-20160816; b=wMQcGnpJrOzgBubUCwclkGbFg/yzqBG510Z3huSJSTusp5uJl7AmmWmjeonANFqKNJ MWo+gHkOydbOMzGw2IDtZbgNU2F8D1rkIxEYeOiYQL5voB0zhsVdDaSr3DWv+35BFUQU z6pawFbE1jxgvkRV+7KHC5nOXebSvbDF5rq5z7EwRtIzUD3wTh1tsPsvuw+0w7cxX4BW FhsS5RlIOce+7SeYpIWkHxOVAMSePT5ZOVIKTMHJeHCOfsNU+JELo91JYwCxP1S4ZH1p g1McWRnAOFyUI7DWA6D82U4Ay2w2fhG2mRPQDXkY/O2jEig/p76GErLRVep9/7TCLf+o 2+ww== 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=65V7+rlKF3qFLcZDuaJ9G3rMSLVFgR3p8dWhgYw2tLw=; b=lJmsg6v2seJ0NhGmlmG0HDgz/uh6840avii0uUJlRFOX7CMzCakEaXwE0g44Kn5WyL 248FH4rq3yFs9fJsudG56+syaPwysIFhIpXTTc33VEMQq7rNSN3Wqs/hvNhAVy/B8Yb1 MkBKYu/o3jNaJQmXO2zga0z7IAr+1zryKs96ZqBRe1JRuj2Bvz3MMJcbjjWm+iqCM5kL vm37LChWFNHmr6+FVzJ0+xAJu7tVOqsXpyxJqvEmPk6eaaJ2nu/wPsVR8gVkzB94X4EF Gwkawjj0UoHGQeiHFjAEMMfoISVcCATNM3r3vZ104yHl3ntFU5Uci1Y+ef5f/kzMW6E2 QOPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zZf0o1/y"; 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 y5si7767703ede.457.2020.11.23.18.05.10; Mon, 23 Nov 2020 18:05:33 -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="zZf0o1/y"; 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 S2388532AbgKWNGY (ORCPT + 99 others); Mon, 23 Nov 2020 08:06:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:34714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733008AbgKWMti (ORCPT ); Mon, 23 Nov 2020 07:49:38 -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 5FE8C2100A; Mon, 23 Nov 2020 12:49:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135778; bh=aF2Qit083VMHBupn40ZKBswaPnTvC1xx6HyFrpg4KDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zZf0o1/yoAFIKbIqBm/Uu+LoTNfMX5F/ebEbeIiUjrY7v+eO6IowqwH57QQ79uPab 6ZjOPkoVdpOj+EW9kZ2deAY377xlcc1TLvX7ulREVT61qsgnkeYEkiuuho/QS9jdae a/FybKk2WcLjIFgkxmT6aEXqMxFCkb4lAj3wDB0A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Takashi Iwai Subject: [PATCH 5.9 193/252] ALSA: mixart: Fix mutex deadlock Date: Mon, 23 Nov 2020 13:22:23 +0100 Message-Id: <20201123121844.912645181@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121835.580259631@linuxfoundation.org> References: <20201123121835.580259631@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 @@ -70,7 +70,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 */ @@ -119,8 +118,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; } @@ -258,7 +255,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");