Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9090957pxu; Mon, 28 Dec 2020 06:25:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwOB2JxejVj1t7rS9ysizEKmpiY4CjY5HQRiE2xwAVYOX82WxDGpzp/TtitvZroJKneQW0 X-Received: by 2002:a50:c053:: with SMTP id u19mr42207488edd.109.1609165501610; Mon, 28 Dec 2020 06:25:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165501; cv=none; d=google.com; s=arc-20160816; b=pGl5sLEbNbSHjTN2u1IWnmbTeBEdqv7ifHMyDkeQCF7fzSpZdWX4nsbkmTsxEvEgTL NSdHvvvbJ6gTD0l4Ody+1j6G1NyejEY5k+MnyF12443MI1wetFVRyN9LTFI2/iJmv7fp eVKzvCvGf6uWPFLLaHIsshWUmL6rfyIXzloUASe9Z/h002hl0pwlso6ZfZpK3aCPh9Ci GVOUOQPYpDMq+EtyeA2FbYE2JzS97RNJDzbsbwOu16nvwZ/bxzYI+zdKVPCbv7MSAGBx RTOY5nE2CyhwU3BXLRwJg3FWhs2moGxZaDnIEhL17KaL0JqrOlClynvnKMDH+HEHtNEh 6UIg== 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=lrLjDsZrnjAKXCwU7EOwVIHjWKnlPodff1ELjRj6A/A=; b=M0N28ME1ZjwYMSKGnEVc6D5//auUMgysrZQ7Z6NaSdiTxaZOPCopVcV/Zmn3JLoXrV shOw1trylG0E5PeqCIXmCAJfA4QKi2geM1HquWLVKDL7Tz8fI5zP3YBoigNxNHetJjek YKxUc+Lx2I/xJCcg6UI9JG+5bbFML8RLkVLnLdInBB4jj1iIzThc4oqtsSOhvTcLJhPv q2/aPdQ61er+JWfkCHrVCLYkOyvbahywbVjvdJFvKoKG/GDY3ejfeLZQRcUhul2buWYr 7rsfhrRZSQv+PlgiPGXq4E/aDSe1CKq7Kt9ed1mSeGLrtPiLOsOrRWZs/OaRE2ydD7K/ gSGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=demQ26Pe; 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 y24si19879260edv.565.2020.12.28.06.24.39; Mon, 28 Dec 2020 06:25:01 -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=demQ26Pe; 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 S2437747AbgL1OUS (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:54492 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437736AbgL1OUQ (ORCPT ); Mon, 28 Dec 2020 09:20:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2CFF52063A; Mon, 28 Dec 2020 14:19:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165200; bh=nNN7379qYIb2U0CIKDVPJ+EpicS1iriHhRc8oW9cDgI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=demQ26PenYyCexaGDjb0P0thx7057YLWXrQfY/2leEc050UMiFeeVqN1teSCI1fvE AibyY8zJQN4rL3gr9koLFvIr3xbRcQR3CqnCPXo+S2JplUPGc5uS8f8DV2EKC07xRC SzoNn5DYddcw7ky9w8DiHusFAa7Yh65hgwlgXKuo= 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 5.10 417/717] ASoC: wm_adsp: remove "ctl" from list on error in wm_adsp_create_control() Date: Mon, 28 Dec 2020 13:46:55 +0100 Message-Id: <20201228125040.939384687@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 e61d00486c653..dec8716aa8ef5 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -1519,7 +1519,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; @@ -1529,7 +1529,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_subname: kfree(ctl->subname); -- 2.27.0