Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3253770pxu; Tue, 15 Dec 2020 02:26:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4iM1ecy2zeZWhuwfjyflDfeigHJXkAxqB+o7sehNDrkTKWzeN2RpOYkeMh4DHHEcnNwxt X-Received: by 2002:a05:6402:1803:: with SMTP id g3mr1774960edy.10.1608028017128; Tue, 15 Dec 2020 02:26:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608028017; cv=none; d=google.com; s=arc-20160816; b=G8ZtrXatwlrwKW0eNv6OKCXTeAQJk66kdsbWc+vPkaBl4/aW1+M27qBcbdWEmWu4Zn Fy/QAXoPKXUohtsxNqmU3UtiJqo5jcV8WW6UU9E2FZpIvtechCAmVNt2MaVn+WyVQLTS U8KforQQZKwk7qez57r/lkqDDowgk7ge+dI+PUJeLpRuxLWhzCa9E+Ih3kSAJo1Ua2gL HIgzCyqFBJJAi7AWIT8t6IE4/b5ejY5py43Eg1C+6CkAKcjN0dt9DU4WG+5Hjjjb+/M+ 0RsWqZlCv+OKzrYm2nfzp0Q+erqZjaKBxUwbp9FMWU6FChGWlir4SFWTCsA53a7Rzt2t KDTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=tvQrv/ItfE78XRSohMF/HJEtdwtZZi+AiD3Wfw82lT4=; b=DtmtErq5udO7b90BC3iXB2BCw2qwgwQ272k2W96H4BZbRVdrIc1nHRVJsgP8+3hYGM TiJh8lPnxT2Y7bViPj0NJZDk3ycNn5Wyz0Rx614mw06X085eGdeh2Qw6xE1no9qamYwt mtGIIREGo+tVtPW9pNNidEC8KAoNzM8cOk0QO2/F0CumYeEIagwCOybJ6B5K+/nCAzgY HqxUmn+IIoxb5GwUjAVbWSZMKLU3j59PzuA93PawpwKrI18rPrdVD9QdfebTK4RrYLZA IM56s0ZXd0HoNh0E9kRwjTbh8T8esx6Sv1y0B6PCWadvG+6RdTaAzAD5ef6y6ve7p1OC igrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=PwGRccYF; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t19si667157eji.402.2020.12.15.02.26.32; Tue, 15 Dec 2020 02:26:57 -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=@cirrus.com header.s=PODMain02222019 header.b=PwGRccYF; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727283AbgLOKYZ (ORCPT + 99 others); Tue, 15 Dec 2020 05:24:25 -0500 Received: from mx0a-001ae601.pphosted.com ([67.231.149.25]:64588 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725535AbgLOKYN (ORCPT ); Tue, 15 Dec 2020 05:24:13 -0500 Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 0BFAMkmt031377; Tue, 15 Dec 2020 04:23:15 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=PODMain02222019; bh=tvQrv/ItfE78XRSohMF/HJEtdwtZZi+AiD3Wfw82lT4=; b=PwGRccYFmlBlAWmufhrIJD0yvLKqLJi0MosBRl7FsXhox0AL77Mj9nDPm+HrBmxW8NZr W/wWLESYPYtqcdwwjvrURPsowQZubuqAwUhI1x7BHbiWL3KRdWy6p5GGhfcgggDU56xP 8pklTAy9DLO8sDeR2gZPUCPB3IsOkue8RF7hn3jD2gMxZmrG8ixal13ijvbNjJBy851a tFF7kbo/tKjBFrzll31oM2audzjTuZkdg3WI4F3G7SDtWYG7tGfrzPXgBe4R0R/PE4Qu NZqTrBHWMsujwiturDSQtVlsz7RhxsCmDALiCpRAY1XvHZx9RxWg7OWtE+uxjFYT5KTX PA== Received: from ediex01.ad.cirrus.com ([87.246.76.36]) by mx0a-001ae601.pphosted.com with ESMTP id 35cv56kkmw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 15 Dec 2020 04:23:15 -0600 Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1913.5; Tue, 15 Dec 2020 10:23:13 +0000 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1913.5 via Frontend Transport; Tue, 15 Dec 2020 10:23:13 +0000 Received: from ediswmail.ad.cirrus.com (ediswmail.ad.cirrus.com [198.61.86.93]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 881E811CC; Tue, 15 Dec 2020 10:23:13 +0000 (UTC) Date: Tue, 15 Dec 2020 10:23:13 +0000 From: Charles Keepax To: Thomas Hebb CC: , Mark Brown , , Takashi Iwai , , Liam Girdwood Subject: Re: [PATCH] ASoC: dapm: remove widget from dirty list on free Message-ID: <20201215102313.GD9673@ediswmail.ad.cirrus.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 lowpriorityscore=0 spamscore=0 clxscore=1011 impostorscore=0 priorityscore=1501 phishscore=0 mlxscore=0 mlxlogscore=999 suspectscore=0 bulkscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2012150073 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Dec 12, 2020 at 05:20:12PM -0800, Thomas Hebb wrote: > A widget's "dirty" list_head, much like its "list" list_head, eventually > chains back to a list_head on the snd_soc_card itself. This means that > the list can stick around even after the widget (or all widgets) have > been freed. Currently, however, widgets that are in the dirty list when > freed remain there, corrupting the entire list and leading to memory > errors and undefined behavior when the list is next accessed or > modified. > > I encountered this issue when a component failed to probe relatively > late in snd_soc_bind_card(), causing it to bail out and call > soc_cleanup_card_resources(), which eventually called > snd_soc_dapm_free() with widgets that were still dirty from when they'd > been added. > > Fixes: db432b414e20 ("ASoC: Do DAPM power checks only for widgets changed since last run") > Cc: stable@vger.kernel.org > Signed-off-by: Thomas Hebb > --- > > sound/soc/soc-dapm.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c > index 7f87b449f950..148c095df27b 100644 > --- a/sound/soc/soc-dapm.c > +++ b/sound/soc/soc-dapm.c > @@ -2486,6 +2486,7 @@ void snd_soc_dapm_free_widget(struct snd_soc_dapm_widget *w) > enum snd_soc_dapm_direction dir; > > list_del(&w->list); > + list_del(&w->dirty); I can't help but wonder if we should be taking the DAPM lock for snd_soc_dapm_free_widgets. However your patch doesn't look like it is making that any more scary and looks like we should be making sure we remove the widget from the dirty list. Reviewed-by: Charles Keepax Thanks, Charles