Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp414602pxa; Fri, 21 Aug 2020 10:27:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0GxqjsLlMcMOnrkXWG4UsdjK6CQMcOlWfwof+V13hpkrABgkY6r8x6tjrzIZVWwCxFGem X-Received: by 2002:a17:907:41dc:: with SMTP id og20mr4023216ejb.183.1598030850069; Fri, 21 Aug 2020 10:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598030850; cv=none; d=google.com; s=arc-20160816; b=gs/y3FS49BzGvtD+RI+li5lkZ1FJn6uh5c9D3wUGWemh0Vd/CSSox60lk2CoLDwLwe UL9aFjVvXDKYOmvRiucYuykEmgP1kNuV99yihn2GrmkXkWJ0FW3NXKOAzBl4WGZ+A9MV l5kHikSjKE1OGduIF6KuP7xZUp1XgDNhJidyCgA/e31n9RJHrMJ+v9giXIl5ooNorhb4 8yUPxdhGjnrp4rmgQIztT8iD5CRmBWLr3UTHBHk2xmaqvj4EC1P6EEvksC5UyBc1N1kP TPR9cWJQaH02bgvRQeEURLLJmmQYop1UEfiIAI6RHmR9nfQmbLC1JEFHxDQp+PhtdS1D eZgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=KTCaVzrz7t12UkQKW3XcbvcUBWaNksrShwg7YG2RcIw=; b=jFcvcTkAINxYydH8lZSbn0erygRXum3cgtM11GlhpUaP8h3yjMgEn+RaEWSUB4vxDT mZ7vSWzOy+HDwl6nhT03FvnTODfZN9U3OkPxylNy++F8nyLqxlcnn5Z8cW5Ys03RkN8w ApuP5TSc0A0GPP/6tBwtPz5gGQY9IOPRPb63oXVTQkJz429qYBXEoHXxmniVgFj97bSP 8O36o1VYmnXZzDnnwszDtUH+n5vdDx5OEv0LBcg+zzgCfycor7z7LM5cZpFHwkkZ4fzd xcdV9WUBxgc3mENl4Ettq7G1dLlmCFc+VSFln00+LO4GI3RF/C44SeFhb4dXltAojZvo 8yMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fDPDiIgS; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si1556395edq.355.2020.08.21.10.27.06; Fri, 21 Aug 2020 10:27:30 -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=@kernel.org header.s=default header.b=fDPDiIgS; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729176AbgHURZZ (ORCPT + 99 others); Fri, 21 Aug 2020 13:25:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:48004 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgHUQPX (ORCPT ); Fri, 21 Aug 2020 12:15:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E929522B4B; Fri, 21 Aug 2020 16:15:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598026521; bh=EJJez6UPPbajUEmbkwY0h8McdlMhZ6j/R+FW9Mk8Q0c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDPDiIgSo3JKgcHY0PofC9eYjlcnIqcafoOB8BRrRONW5iHBX/tPRroGMy7bi363I K8qjAHGCcVa37f4WPONs3OviaapTPrioTOLqf4x8FKM4O4FA9UgCuetTPr76mexY1o 7WKIs3tYxTJO1UmdZDqSDi6Vx1GXLeUN5RFENHjg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Pierre-Louis Bossart , Bard Liao , Kai Vehmanen , Mark Brown , Sasha Levin , alsa-devel@alsa-project.org Subject: [PATCH AUTOSEL 5.8 45/62] ASoC: Intel: sof_sdw_rt711: remove properties in card remove Date: Fri, 21 Aug 2020 12:14:06 -0400 Message-Id: <20200821161423.347071-45-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200821161423.347071-1-sashal@kernel.org> References: <20200821161423.347071-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pierre-Louis Bossart [ Upstream commit cf0418cd06ce42fcf35beb33e315b5a77e596926 ] The rt711 jack detection properties are set from the machine drivers during the card probe, as done in other ASoC examples. KASAN reports a use-after-free error when unbinding drivers due to a confusing sequence between the ACPI core, the device core and the SoundWire device cleanups. Rather than fixing this sequence, follow the recommendation to have the same caller add and remove properties, add an explicit device_remove_properties() in the card .remove() callback. In future patches the use of device_add/remove_properties will be replaced by a direct handling of a swnode, but the sequence will remain the same. Signed-off-by: Bard Liao Signed-off-by: Pierre-Louis Bossart Reviewed-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200717211337.31956-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/intel/boards/sof_sdw.c | 1 + sound/soc/intel/boards/sof_sdw_common.h | 1 + sound/soc/intel/boards/sof_sdw_rt711.c | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/sound/soc/intel/boards/sof_sdw.c b/sound/soc/intel/boards/sof_sdw.c index 1bfd9613449e9..95a119a2d354e 100644 --- a/sound/soc/intel/boards/sof_sdw.c +++ b/sound/soc/intel/boards/sof_sdw.c @@ -184,6 +184,7 @@ static struct sof_sdw_codec_info codec_info_list[] = { .direction = {true, true}, .dai_name = "rt711-aif1", .init = sof_sdw_rt711_init, + .exit = sof_sdw_rt711_exit, }, { .id = 0x1308, diff --git a/sound/soc/intel/boards/sof_sdw_common.h b/sound/soc/intel/boards/sof_sdw_common.h index 69b363b8a6869..fdd2385049e1e 100644 --- a/sound/soc/intel/boards/sof_sdw_common.h +++ b/sound/soc/intel/boards/sof_sdw_common.h @@ -84,6 +84,7 @@ int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, bool playback); +int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link); /* RT700 support */ int sof_sdw_rt700_init(const struct snd_soc_acpi_link_adr *link, diff --git a/sound/soc/intel/boards/sof_sdw_rt711.c b/sound/soc/intel/boards/sof_sdw_rt711.c index d4d75c8dc6b78..0cb9f1c1f8676 100644 --- a/sound/soc/intel/boards/sof_sdw_rt711.c +++ b/sound/soc/intel/boards/sof_sdw_rt711.c @@ -133,6 +133,21 @@ static int rt711_rtd_init(struct snd_soc_pcm_runtime *rtd) return ret; } +int sof_sdw_rt711_exit(struct device *dev, struct snd_soc_dai_link *dai_link) +{ + struct device *sdw_dev; + + sdw_dev = bus_find_device_by_name(&sdw_bus_type, NULL, + dai_link->codecs[0].name); + if (!sdw_dev) + return -EINVAL; + + device_remove_properties(sdw_dev); + put_device(sdw_dev); + + return 0; +} + int sof_sdw_rt711_init(const struct snd_soc_acpi_link_adr *link, struct snd_soc_dai_link *dai_links, struct sof_sdw_codec_info *info, -- 2.25.1