From patchwork Fri Apr 14 19:11:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 9681663 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 64F2060384 for ; Fri, 14 Apr 2017 19:11:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51CE0285A8 for ; Fri, 14 Apr 2017 19:11:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 44BDB286BA; Fri, 14 Apr 2017 19:11:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E561285A8 for ; Fri, 14 Apr 2017 19:11:49 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id C8B59267227; Fri, 14 Apr 2017 21:11:47 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id E3A9226722B; Fri, 14 Apr 2017 21:11:45 +0200 (CEST) Received: from userp1040.oracle.com (userp1040.oracle.com [156.151.31.81]) by alsa0.perex.cz (Postfix) with ESMTP id 24C7F267212 for ; Fri, 14 Apr 2017 21:11:39 +0200 (CEST) Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v3EJBa6d008113 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Apr 2017 19:11:37 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v3EJBYeQ020460 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 14 Apr 2017 19:11:35 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v3EJBWv3017189; Fri, 14 Apr 2017 19:11:32 GMT Received: from mwanda (/197.254.35.146) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 14 Apr 2017 12:11:31 -0700 Date: Fri, 14 Apr 2017 22:11:20 +0300 From: Dan Carpenter To: Liam Girdwood , Jeeja KP Message-ID: <20170414191120.GA30875@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.6.0 (2016-04-01) X-Source-IP: userv0021.oracle.com [156.151.31.71] Cc: alsa-devel@alsa-project.org, Dharageswari R , Vinod Koul , Pardha Saradhi K , kernel-janitors@vger.kernel.org, Takashi Iwai , G Kranthi , Mark Brown , Hardik T Shah , "Subhransu S. Prusty" Subject: [alsa-devel] [PATCH] ASoC: Intel: Skylake: Fix a couple user after free bugs X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP We need to use the _safe() version of list_for_each_entry() here because of the kfree(modules). Fixes: b8c722ddd548 ("ASoC: Intel: Skylake: Add support for deferred DSP module bind") Signed-off-by: Dan Carpenter diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 600faad19bd4..d43d1976dd3b 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1323,10 +1323,10 @@ int skl_platform_unregister(struct device *dev) { struct hdac_ext_bus *ebus = dev_get_drvdata(dev); struct skl *skl = ebus_to_skl(ebus); - struct skl_module_deferred_bind *modules; + struct skl_module_deferred_bind *modules, *tmp; if (!list_empty(&skl->bind_list)) { - list_for_each_entry(modules, &skl->bind_list, node) { + list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) { list_del(&modules->node); kfree(modules); } diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 74b3acf3bb07..aea7917e791c 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -1091,7 +1091,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, struct skl_module_cfg *src_module = NULL, *dst_module; struct skl_sst *ctx = skl->skl_sst; struct skl_pipe *s_pipe = mconfig->pipe; - struct skl_module_deferred_bind *modules; + struct skl_module_deferred_bind *modules, *tmp; if (s_pipe->state == SKL_PIPE_INVALID) return -EINVAL; @@ -1105,7 +1105,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, src_module = w_module->w->priv; - list_for_each_entry(modules, &skl->bind_list, node) { + list_for_each_entry_safe(modules, tmp, &skl->bind_list, node) { /* * When the destination module is deleted, Unbind the * modules from deferred bind list.