Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9045085pxu; Mon, 28 Dec 2020 05:17:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIXgjO4vSG/YpOOXZi+5UHZdJXf1eEJ6TdaFw7Ez8mIE/ozbJanxC1DmXnzSAxZ+jZ7xwy X-Received: by 2002:a05:6402:3192:: with SMTP id di18mr41500130edb.332.1609161453028; Mon, 28 Dec 2020 05:17:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161453; cv=none; d=google.com; s=arc-20160816; b=XlmGMj4CMSlt8BL2HwatqAvcUEMUjzYZhzTDxIaGY91qpsVmdL6Ds7U0owKCxvFiQa WTKU3G5KZ76nVr/7b1UOG3flNDsW+KyviWB6Vn4XwUCkplSUqW+NRfDzTIDcnmR9rPxe GhZx46VCraoIHKtjSSn+mpwKLuSVOiUq641LWhjEL/OO1D4lERFJrEx0A4ArfmFo2+67 S292ihknMS3T9mJk7P7cmIY8RMLRBIYR2paOppxDHd749Y8pfQUxePTIrEZpNuDc6CY6 zxcVLSMccveWuW4a12lKJcGqDNPLVixGNqWMnatCFVvngIQAIk3ePOjdrPfm8in0RzgL H4+Q== 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=NN+7Ef0XnEZpRYbvhXnuCcUX5Qy/yBepNkrKZiTtoJg=; b=JUnNdWKmcNM1pO5GcVhpyrcZc/zdP5i0/uQfKcJl0wRZFvWTcNlfTu/TBTpxFs0+ks DAv2NRkDuLRrD82sBjwncvLygdsTzSsefSxrcPWk+/wyMzwsp44v+ein3HacF/L0cHhY Eb6ZnOWg5EJzaH0xI7Fg57E0GqqKRJSyGyWRydZp5vhUBt7FmBmilsTsAX8kzKflW5QU Or90o6v0djKvl6L2X4atoxMsnCU9chVy3LAx8AzNkxCwa2j4FbCox9JnF6SqiRmfhzyW RvGV/aPDK02yhCu91lzbY2FLQ1zdcJCmFgxqO0ydnW08EGMwq54hT6TBIejKrFhx+5Bt 4onQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="i/DIz+Tm"; 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 ce20si21777122edb.138.2020.12.28.05.17.09; Mon, 28 Dec 2020 05:17:33 -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="i/DIz+Tm"; 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 S1732643AbgL1NPN (ORCPT + 99 others); Mon, 28 Dec 2020 08:15:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:43424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732626AbgL1NPJ (ORCPT ); Mon, 28 Dec 2020 08:15:09 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0492B208D5; Mon, 28 Dec 2020 13:14:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161268; bh=LD53EuW78+nIuuED95cWG7ISgb2eJLTE/RViJDF/wkw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i/DIz+Tm2MNTMahYSi1xVMw3eOCaK8povPbO/jqlc3cazAcisTtpNJPLktqAWlsnR 9KcKtu4txGN3/1rYfDBJTO6G5+NAdc0LNOC59RbD8qoGLJr5Tmriwe9zGW/LTXv5aC k5yhCb39ufKoZ143DfXI0gnPwjPKFJbMkn/Ldl9k= 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.14 158/242] ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control() Date: Mon, 28 Dec 2020 13:49:23 +0100 Message-Id: <20201228124912.481993035@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 158ce68bc9bf3..1516252aa0a53 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1391,7 +1391,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; @@ -1401,7 +1401,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