Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1327796pxu; Mon, 23 Nov 2020 18:42:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJySt0qbAv/hLcyEy9eIWsWX5nRU8g7mWScI3XSPJpjEgzX9opeOzbo23ZiraZOv66ifzjmt X-Received: by 2002:a50:bf4a:: with SMTP id g10mr2144476edk.288.1606185759591; Mon, 23 Nov 2020 18:42:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606185759; cv=none; d=google.com; s=arc-20160816; b=RtueO2GJXb/n6Kx7JrxBnBY5rFR1mIEgTloidiQjxdS0EcHzIwjUuomdYJS023WRfc JboxtoCwbIpcQr14IlCxgH6zChZMunFbJrgLvDdbVYcDvEKcagDooh4oI5QQbMKqU+ET ow+rMKlf57KQHjWvxGyHAzJ5PThXtzp8rRZ+nW8AKzKKkKnOfeN1A6b1fyzHKejQKN27 BpSuM4QUgrUq/WAmOtPc1uFWmPBPAfrt15+N40oq+z2NojD+4b59YnFTQxGJu27kT6kp T+Rt6e5y1khtl1dFwjsx52SvHGkRcUGK64zOuO3w8WDpxXRK9wEIUN+T3V9Na7UxUYnn Lh+A== 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=Qs0L9myZ0cpfTUngbpBqoFWEaIfq6KbHS9Gah50isjb0QKBMJlkAiQ5vvjfQjVB8ju O6Cq5F5KiMlewevKIQi/gt9WsERVczPjgJdduUrgT3Bem4s6+Jn0FMbfeN16pgxmonEb KgiU/6lGNORttI7DRhJRiuQZzR2weNC//80p1mSlZAG4IR29dQMs8MKscoUpmDaJnYKE F9HWi1yZKfLOlXp9svE2xIL0oYZbgz5SPts/z4xlLVWSJYD9POTYXl5c+GjshGEINmkw 8Sy++2Gb8yISjfXg9b63Ce1kB6EJpml6Q1Hg2KdYanya2H4jK7iDXb2axwCDTmTzc5f0 uyeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oq+iY52X; 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 y25si7576524ejd.556.2020.11.23.18.42.17; Mon, 23 Nov 2020 18:42:39 -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=oq+iY52X; 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 S1733197AbgKWNUY (ORCPT + 99 others); Mon, 23 Nov 2020 08:20:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:52114 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732137AbgKWMjY (ORCPT ); Mon, 23 Nov 2020 07:39:24 -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 13BD220732; Mon, 23 Nov 2020 12:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135164; bh=aF2Qit083VMHBupn40ZKBswaPnTvC1xx6HyFrpg4KDI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oq+iY52XOlVDLKjpiiLmfguauN5qr1kRUF26pfqLGl+byT6Zhe87EAm+gE7N3Ztf2 0n/WkiOdV69vOH5ZlPMEOh1RcbbAn6Oup8R1hpTTuiZoIhldNlQZK/f+p7tXbCnVEr a6hKQnmyJC0heqksgdqlvuvNODIx/Ublo6qfuXh4= 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.4 120/158] ALSA: mixart: Fix mutex deadlock Date: Mon, 23 Nov 2020 13:22:28 +0100 Message-Id: <20201123121825.722909073@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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");