Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2056389rdb; Tue, 3 Oct 2023 08:59:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGNl7GQWn+V8ll6gr2+SzW0dXyKKfcVLYE47qbDHYEaLqhE+gdRysSjfrmXVvLp8Ko9S2pa X-Received: by 2002:a17:90b:4a8b:b0:279:6fbf:ff6f with SMTP id lp11-20020a17090b4a8b00b002796fbfff6fmr6353693pjb.37.1696348763971; Tue, 03 Oct 2023 08:59:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696348763; cv=none; d=google.com; s=arc-20160816; b=QLyQt1wZIEr3awAPw0lNH+bjzwuKPIj/CHbrJVQPwfdo4wBp5D5ZPfkZp1fhfpVgz4 OJ466rYzt1uFitbRYtpQ9czPXF6MNXql+TWA9QGtopm+X44QGnie5gZ3n1gLMrYMcn/w EnhQylVYJxk+qxZf5eRgF5MzaMWvtq1UJ23qkbZytO7Wau5nyaKGen+jnUj97CnTwOlb JSZxkeP0qCWg4GgV/ScuPoxAybEumTNMJy66OI4Zx45bv9OSJnkAir14VTxIsNYkamY6 PfObraIHzNuEFmGro587nq9zmZE/dm4qAfQL1aQcS1WH+EYLTMcnKT1c/Mqw4bYrmvhH Vpcg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8Drub6jttImh8BylYXL05GN5RypZlTM35RmaosCPGqc=; fh=A7ESGAPW6WV+DCQVqmR+9L9s97lYo7gbF/gPHfKJi14=; b=dcrKOYpcaIqX/U60cUReORkgVdI04pVLMbx0zSCWjFEo2HaXU0Wk3ba/g4PyxcRKFX 3OAIHFXZ0UEAAZJuv7m34zYsy1dlQWCIJWQkvCQfAdl3vzHrbz+Klaa1GummenIz4gbN 5peJFNZwm01QDr9dK2hrg9dfV+wCZVi6nMZfxElbYvEEm3NkdMlCGZV7TjvCrI31frSY LcgxKis93p2iJKVfDYPtFrLnqltWTZeEYfJUkBdo3OSECs6aJtDBl3n+AekBO1oqmwcO SWAxF6BvNZ10zKmoiLdY6jNESutkhB8P9QCMWgotcbVLVP/3EtkbGTJrWZVLgduz/Vzw m+JQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q0yACS9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id s5-20020a17090a440500b00263f3c1bb86si1632607pjg.158.2023.10.03.08.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 08:59:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q0yACS9I; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 69C8580EE79F; Tue, 3 Oct 2023 08:59:15 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240298AbjJCP6z (ORCPT + 99 others); Tue, 3 Oct 2023 11:58:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239359AbjJCP6g (ORCPT ); Tue, 3 Oct 2023 11:58:36 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B7D39B0; Tue, 3 Oct 2023 08:58:32 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E4AAEC433CB; Tue, 3 Oct 2023 15:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696348710; bh=2DhAHBo+YbBdItb8HnA01InHv+0f3MquKuWsrN91pvQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q0yACS9I5mo04/f0p1lkuf9QE0h/FBp1VdvpIubCClTCduooBHTGsehbanfK6yFvr 3d8ujJR0Gt/HlsJsczhxWFnef/uOGAfKSriVeQMl5hfqfrk6NOaLe+O5EaPctUWU1z +QSkqUWkWnPx+BvrCmKjWSkvqhDzubLJzNnqEFTPwpFpZg3UX6XdnBtW4No9ZVrsBG zMZKn/1N8amwOwczJjtASlirvoX3vZQl4towl66BWWGHiQUHRFrKy3C3auyGuRlF79 mrk4YBN1ph1ItMh67p8ApqzWEsINR+BzKnV6LA8a9IpbAnCrnYR6A1Je6+1/Su5Ws5 RKSGUTLwkQGzQ== Received: from johan by xi.lan with local (Exim 4.96) (envelope-from ) id 1qnhnG-00074z-13; Tue, 03 Oct 2023 17:58:42 +0200 From: Johan Hovold To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Srinivas Kandagatla , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 6/7] ASoC: codecs: wcd938x-sdw: fix use after free on driver unbind Date: Tue, 3 Oct 2023 17:55:57 +0200 Message-ID: <20231003155558.27079-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003155558.27079-1-johan+linaro@kernel.org> References: <20231003155558.27079-1-johan+linaro@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 03 Oct 2023 08:59:15 -0700 (PDT) Make sure to deregister the component when the driver is being unbound and before the underlying device-managed resources are freed. Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver") Cc: stable@vger.kernel.org # 5.14 Cc: Srinivas Kandagatla Signed-off-by: Johan Hovold --- sound/soc/codecs/wcd938x-sdw.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c index 6951120057e5..1baea04480e2 100644 --- a/sound/soc/codecs/wcd938x-sdw.c +++ b/sound/soc/codecs/wcd938x-sdw.c @@ -1281,6 +1281,15 @@ static int wcd9380_probe(struct sdw_slave *pdev, return component_add(dev, &wcd938x_sdw_component_ops); } +static int wcd9380_remove(struct sdw_slave *pdev) +{ + struct device *dev = &pdev->dev; + + component_del(dev, &wcd938x_sdw_component_ops); + + return 0; +} + static const struct sdw_device_id wcd9380_slave_id[] = { SDW_SLAVE_ENTRY(0x0217, 0x10d, 0), {}, @@ -1320,6 +1329,7 @@ static const struct dev_pm_ops wcd938x_sdw_pm_ops = { static struct sdw_driver wcd9380_codec_driver = { .probe = wcd9380_probe, + .remove = wcd9380_remove, .ops = &wcd9380_slave_ops, .id_table = wcd9380_slave_id, .driver = { -- 2.41.0