Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3520559pxf; Mon, 15 Mar 2021 11:23:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSSOC3C2/RO8bibc2DY7uS1sRjC/B4o7F+FLkztNpUwNMHhd154sFfZ6A8if8rOPXG4qGd X-Received: by 2002:a17:906:3e89:: with SMTP id a9mr8541569ejj.405.1615832588525; Mon, 15 Mar 2021 11:23:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832588; cv=none; d=google.com; s=arc-20160816; b=SLnIOJ8/Jl44lqTfCegG2vKD3jD8MNvEbgLK8LANi6Ij9mxLpH8NwJAPAzahxHQHs5 aElryBECjA8nDOWUguiXJagUDLlRCg2ApD4Nnbkg5ryAV7wY+QAYceWOP66/BY5vQLoo Edti5ZK6Wn7u0ySPro+KOf3vwWaBMzoGfSSNi3OvUMNFhFz/Jb1Zp+bY8prWcuY7I6Ba OTM+5hJpJoK4CGjlzkD7bPQ6MgwS7MtfT2k38TCIz/yA4zSPxGrO0KPvJH+Kq6H7VAa9 gXLMDn7qe78mLu2lvYZKic/7m9GjH/3Y+C3oVV98QhOepf7QjUEYAcGcLfyeY3P94CnC AJQg== 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=n0iO3mnlANerdvkW6ZB/pZF0J4wWKqda5bHyBNeaRJU=; b=WqKnB3eSFZu8DIsJ0PjO9qJwd+wTm91f8IY4k9ney4uWVlO8/UkWPrf/8cn+7b7hwL fy5zw2JBMUqzS43x70DfRWI9UJHtmvR9o0pKYEg/gMbwcxWWy+CsrRdkqHlMvZCIDLie ZVJWI9G8UoW/F6Cdyv+ZIzzKBEp1VBpHe5eq2FD4QT/yc3/VWcMfs+xqNk/MM83t+MzI 2d357zi1uWByyvEit3QFR2ij8yK7enmQObHjIT2ObXRnNhCzk+RSQ/teq6YAnCaTSQ/9 PgiRvNxgXUcBv239bZ3dTpLg/GoVMqFeaE1sdXYr9KCPsQ0huZYMKkE4N5a6oxlQwzHX lnpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=KIYA1N3G; 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 b21si11126360eju.469.2021.03.15.11.22.45; Mon, 15 Mar 2021 11:23:08 -0700 (PDT) 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=KIYA1N3G; 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 S237760AbhCOOT4 (ORCPT + 99 others); Mon, 15 Mar 2021 10:19:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:37476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231576AbhCON7v (ORCPT ); Mon, 15 Mar 2021 09:59:51 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C04E864F29; Mon, 15 Mar 2021 13:59:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816772; bh=1+oiQI9T+BEZ7+cq5WdB+SVZL/j02OZ6fOiHXpw0xMY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KIYA1N3G2fAZDIWkWIUy61ho+aFSd+mmyYZJHU2ODTUxc0XUHbLXxUMpyW0jAUlDO r/FJWWy/Z4E1z8mqf3t2DkYUDKT64QakOOnxaZQio7f6506TmAQmofdhLnLZNJyq/8 dY+pvuBqx1OETGQlaOkNppAWsh7NQ86XVjEE34WQ= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maxim Mikityanskiy , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 5.11 116/306] media: usbtv: Fix deadlock on suspend Date: Mon, 15 Mar 2021 14:52:59 +0100 Message-Id: <20210315135511.575045693@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135507.611436477@linuxfoundation.org> References: <20210315135507.611436477@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: Greg Kroah-Hartman From: Maxim Mikityanskiy commit 8a7e27fd5cd696ba564a3f62cedef7269cfd0723 upstream. usbtv doesn't support power management, so on system suspend the .disconnect callback of the driver is called. The teardown sequence includes a call to snd_card_free. Its implementation waits until the refcount of the sound card device drops to zero, however, if its file is open, snd_card_file_add takes a reference, which can't be dropped during the suspend, because the userspace processes are already frozen at this point. snd_card_free waits for completion forever, leading to a hang on suspend. This commit fixes this deadlock condition by replacing snd_card_free with snd_card_free_when_closed, that doesn't wait until all references are released, allowing suspend to progress. Fixes: 63ddf68de52e ("[media] usbtv: add audio support") Signed-off-by: Maxim Mikityanskiy Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/usbtv/usbtv-audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/media/usb/usbtv/usbtv-audio.c +++ b/drivers/media/usb/usbtv/usbtv-audio.c @@ -371,7 +371,7 @@ void usbtv_audio_free(struct usbtv *usbt cancel_work_sync(&usbtv->snd_trigger); if (usbtv->snd && usbtv->udev) { - snd_card_free(usbtv->snd); + snd_card_free_when_closed(usbtv->snd); usbtv->snd = NULL; } }