Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1237533pxu; Mon, 23 Nov 2020 15:35:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJxu0SCjYZLGlRHIliQ0aX1v1NiWtb16+Kav0rpsIu5ZPJuBFcBbLZpbaY1Un9pHkS3Km9N6 X-Received: by 2002:a17:906:f05:: with SMTP id z5mr1937512eji.8.1606174519422; Mon, 23 Nov 2020 15:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606174519; cv=none; d=google.com; s=arc-20160816; b=P2+Q+58YiCK+zjR6RSJraiZBtQrGiwofEBJIGzGJD1Z1TbVUug9UbmXL2tn0OXedCq XxdDqMoxM/3sX+/E+pTsW2j387JHcO2HP1A++/2LQuCPufY2YGMFNsX2NHoH+pZQpD0M o2YLL/+qc7tlHKKsvr8sooDj/ZGl0vW/d/0vOBjgQNElTunbBqufkvvXynVhBoTFE60/ fanSmjd7gM9uJWLoARwc+dI4dNaUN989rqloHZq7sIp8ywdvJN0Y1sQkx3zaB5btidk/ al0CRZ6OspygqfZ89cBswveoGnMvJCuFMpFiKcwR28SfwHBdLDBk1FQDUqDJrBZg/n9v eEJg== 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=xNr3FchwBnrzlcgn5nW/CvlLTg/e3ZawTkNUoqxHD6N3eh8ZydmxStAXc4qqfMkI9+ 1QpdvBVYqW1lXXGaj+7NkxH5XP5xUTOP1pYDp6PwgvMck4DlT6JJtblFF92q8Hqk7MEk GEzGQ3jDpYuEIR/Wn3uyP0vmG/vjgsMuk4z4VUZZ6PQMkck1HNM+DcJ2e7mwff9Ll/gn bGtS4pmdTajsqVH9dDDZ3zkLnOamXd/BL+uQ0XKhTneJYR4Pav1GyS28W5SxIIwG+hnN EHSWiVGd1+ljzglWJMaLXK1gQje2htMjqYRkRwjkpw4CfVyjEDv3RUSniMTw6EDF/U3f Tdfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0ksHPche; 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 a14si7588205ejs.111.2020.11.23.15.34.57; Mon, 23 Nov 2020 15:35:19 -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=0ksHPche; 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 S1731260AbgKWMdn (ORCPT + 99 others); Mon, 23 Nov 2020 07:33:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:44958 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731244AbgKWMdh (ORCPT ); Mon, 23 Nov 2020 07:33:37 -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 E96A320721; Mon, 23 Nov 2020 12:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134816; bh=YoQDnUTsqVY+WKspD6+ZqPA26Klmis3QpVjN5O9GZjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0ksHPcheyuBYaYosHiKznGlGizn8WFqy5SxI1P2rPdhfL048raqZWzUjhdUeDYB3D KO1glFF1KayKc9VAyLpybxVrjjwrDDMjNDHT+kCZJnsKD2toW9jIrI+BUrMouiW+gD vFvSkdfK5a3JL+9/Dsn0BVJBitw94dePaXXuOMoE= 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.19 70/91] ALSA: mixart: Fix mutex deadlock Date: Mon, 23 Nov 2020 13:22:30 +0100 Message-Id: <20201123121812.727253198@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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");