Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9038156pxu; Mon, 28 Dec 2020 05:07:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJyvsNAHZdWcfcyXdQbgfN76DUewddSzHCApiNO0LRrcqOTXY7MwbqUnI4vm76S4EeYizp8n X-Received: by 2002:a05:6402:c95:: with SMTP id cm21mr42399125edb.294.1609160835560; Mon, 28 Dec 2020 05:07:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160835; cv=none; d=google.com; s=arc-20160816; b=VFP/NitlzEtFdm4DPptHyk8Uiyvs8lVkOot4t5gdsdON5Bui9E0XypSvzsHB2+vdbD +0Aodb7e/yNSr0rfB8iJb27ZBU75wyzb41ILnIjIzNIhI8pIVHoGiCC3vVcR4zNv7glH 0P0loopVZI0CdLydfQvxeN20Lk6lUhfKPJBgz/eQgjc0VyNBeptv81D9GAyLz05d7ZY9 gBSYPbjl+npbOnPGFekpC/kMQ71fN6/yrfXT9mSEUpIhFjtfNz0lV586yrhSlTcI5ghz oPqf3n1YLCZUfachVJ9ETMPnfLd+uEjXzIavESr+d59rkN0fVXs4/nahXZ7EdTRtLUVI McPQ== 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=cVdVO1IkUqW8/JC0LwlreP3uDU2anQnm0hdxAzNk/ps=; b=fM/SQgfh4ZWXGFxGY1p4nXRu0yTfiRqTxtyrFw57BrY5CCevaQGfQHA5e+3JPvMsdY mpfaJFXJQxrmUwLtV87zsv0HgzS39N93++HVJPMzuQP3c7yzn+nzNVOyuFBrfAUEiem1 zak3jEbUT1Pg2OGWP8h2XSOoG7t8FEM0AaS0DNTmyOTbeA37F9gGYc8yBNsAdhnyRAGQ F1Q6BEdNS0H1a07gTP3jmkIgkyivszm0Sssy0KQGQGDbcg5/9ctk04kg8od1adORWn22 feCU8d7GAaENN0YfhwbSa+zGEH2DD89ceY8HK+fnWGi0KrIftVIC1opBFWDJXj+swywT Oisw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tA7SKwCS; 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 gt24si19316134ejb.248.2020.12.28.05.06.52; Mon, 28 Dec 2020 05:07:15 -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=@linuxfoundation.org header.s=korg header.b=tA7SKwCS; 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 S1730465AbgL1NEl (ORCPT + 99 others); Mon, 28 Dec 2020 08:04:41 -0500 Received: from mail.kernel.org ([198.145.29.99]:60522 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730437AbgL1NEZ (ORCPT ); Mon, 28 Dec 2020 08:04:25 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6166422AAD; Mon, 28 Dec 2020 13:03:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160625; bh=vPiaashSEX8gxRguCs74Y+WbjVCYfj1pZ+KOXv7UFrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tA7SKwCSWpFigTFvfLe0wmt5yS9096qZiE0TIogxs8vrYfi1aC3WlTuJlT631Mz0n UiglyivWXBkQTFJzCa/yO6sL8LpjHLhQ1VctSGWqa431wJWVAglaog0XehzzzdxGb7 l5wNNYJIlEGx0Mvz5kfP67HO22eltJ6alGMjUwBE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 4.9 114/175] ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control() Date: Mon, 28 Dec 2020 13:49:27 +0100 Message-Id: <20201228124858.775092340@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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: Dan Carpenter [ Upstream commit 85a7555575a0e48f9b73db310d0d762a08a46d63 ] The error handling frees "ctl" but it's still on the "dsp->ctl_list" list so that could result in a use after free. Remove it from the list before returning. Fixes: 2323736dca72 ("ASoC: wm_adsp: Add basic support for rev 1 firmware file format") Signed-off-by: Dan Carpenter Acked-by: Charles Keepax Link: https://lore.kernel.org/r/X9B0keV/02wrx9Xs@mwanda Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm_adsp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 28eb55bc46634..00dd37f10daff 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1156,7 +1156,7 @@ static int wm_adsp_create_control(struct wm_adsp *dsp, ctl_work = kzalloc(sizeof(*ctl_work), GFP_KERNEL); if (!ctl_work) { ret = -ENOMEM; - goto err_ctl_cache; + goto err_list_del; } ctl_work->dsp = dsp; @@ -1166,7 +1166,8 @@ static int wm_adsp_create_control(struct wm_adsp *dsp, return 0; -err_ctl_cache: +err_list_del: + list_del(&ctl->list); kfree(ctl->cache); err_ctl_name: kfree(ctl->name); -- 2.27.0