Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5232263ybl; Tue, 27 Aug 2019 01:13:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk/YTyrlvyG5ToXckark3Zj1xXD9rBaid/tCjtWnBeezuVRN51+78Do8LlpcquOYtUFmRe X-Received: by 2002:a62:6489:: with SMTP id y131mr15620451pfb.124.1566893624504; Tue, 27 Aug 2019 01:13:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893624; cv=none; d=google.com; s=arc-20160816; b=v0Lb4B5Z1Ahyx+d+oKejlsTlRbIh2PFfGFyiVK2vLFAa+e+yEd9KwfU+bjmgx6P+V/ R9NLYlcWniGpXpZibaEo/kjZYUhKXNwk+Fi8vNszuu9fuKVW+BNr5MKfMyvu2u1sIC9h nbAKqcQ7GVGA4xFKg1GjBlezHJmK/GfNMh8LhoHukCDdw5rBUEMwXHgha1erKii30K4G KsUcl854I7mCLwQc/xiPxN3oUMJ+sMT+c36j3Dujg4kuOtGtGRP/mTJj2BLOt1j1UiV+ Fg0aXUvVHcTOIPQ4uxGbSIcf+06ygvTht054VODavF8l50wV+yE7iLrouUoGw+Q27jjx r5KQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1e5TONCCFpo37V77I/N94j4lVJDS0F/dWBuTLbaEcmA=; b=PbB8cwKMKCoxZzEKjz/5sLPmxhxZ32y3bMx9+BKSvxNJ97Ha0OpvUThsYzDq9mtHzo CBxYK8A/djV2Dy1Uteu8/ve0ZLYx424+7oB6xFUPwMrJeTkr67LWQ8ww288XYoExQ0KI v7ApkgMH1S2FFtpN6EA/Z8wkJPEdkdY5cdTi0PkoWlqcr7UTz8kH0IOZ0atgfNy3FE4N e/xJlNmxTV84HvC/v4gt544PHVCoRj72LltJtR/blAaW/KL+lP8ltKroUs7V0i54Enrd hE8Jl0XWuOkAX99ZFsPiy/A3lCyEM8RwCNVW7uv4C8ltZy0MdA2pm/LNqZ9UNhG1N8Fi CcRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NycfPJly; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x21si7493354plm.432.2019.08.27.01.13.29; Tue, 27 Aug 2019 01:13:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NycfPJly; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731271AbfH0H7o (ORCPT + 99 others); Tue, 27 Aug 2019 03:59:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:53410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731269AbfH0H7l (ORCPT ); Tue, 27 Aug 2019 03:59:41 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1C5C320828; Tue, 27 Aug 2019 07:59:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566892780; bh=R3Og+TakvQWnyr0QFYnWiCQpa2EOjzyClBjSC6xllaQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NycfPJly/Gs9856Tjdn5ctbkDGi3N0jmrQs34lqX1eBFxo6OnHMrCIL6fUwf1wYyb yu4cxd19G3cbU1eKzkDppyaF01XWKYF5pwRksZ7427EJSCqsOakFdufSs+2mUFIYOD xlq5/6hTWlyZFO+R6yDPcGVTwYidY62hWEQda7QA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.2 002/162] ASoC: simple-card: fix an use-after-free in simple_dai_link_of_dpcm() Date: Tue, 27 Aug 2019 09:48:50 +0200 Message-Id: <20190827072738.229896213@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 724808ad556c15e9473418d082f8aae81dd267f6 ] The node variable is still being used after the of_node_put() call, which may result in use-after-free. Fixes: cfc652a73331 ("ASoC: simple-card: tidyup prefix for snd_soc_codec_conf") Link: https://lore.kernel.org/r/1562743509-30496-2-git-send-email-wen.yang99@zte.com.cn Signed-off-by: Wen Yang Acked-by: Kuninori Morimoto Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/generic/simple-card.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 9b568f578bcd2..544064fdc780c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -138,8 +138,6 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, li->link++; - of_node_put(node); - /* For single DAI link & old style of DT node */ if (is_top) prefix = PREFIX; @@ -161,17 +159,17 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, ret = asoc_simple_parse_cpu(np, dai_link, &is_single_links); if (ret) - return ret; + goto out_put_node; ret = asoc_simple_parse_clk_cpu(dev, np, dai_link, dai); if (ret < 0) - return ret; + goto out_put_node; ret = asoc_simple_set_dailink_name(dev, dai_link, "fe.%s", dai_link->cpu_dai_name); if (ret < 0) - return ret; + goto out_put_node; asoc_simple_canonicalize_cpu(dai_link, is_single_links); } else { @@ -194,17 +192,17 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, ret = asoc_simple_parse_codec(np, dai_link); if (ret < 0) - return ret; + goto out_put_node; ret = asoc_simple_parse_clk_codec(dev, np, dai_link, dai); if (ret < 0) - return ret; + goto out_put_node; ret = asoc_simple_set_dailink_name(dev, dai_link, "be.%s", codecs->dai_name); if (ret < 0) - return ret; + goto out_put_node; /* check "prefix" from top node */ snd_soc_of_parse_node_prefix(top, cconf, codecs->of_node, @@ -222,19 +220,21 @@ static int simple_dai_link_of_dpcm(struct asoc_simple_priv *priv, ret = asoc_simple_parse_tdm(np, dai); if (ret) - return ret; + goto out_put_node; ret = asoc_simple_parse_daifmt(dev, node, codec, prefix, &dai_link->dai_fmt); if (ret < 0) - return ret; + goto out_put_node; dai_link->dpcm_playback = 1; dai_link->dpcm_capture = 1; dai_link->ops = &simple_ops; dai_link->init = asoc_simple_dai_init; - return 0; +out_put_node: + of_node_put(node); + return ret; } static int simple_dai_link_of(struct asoc_simple_priv *priv, -- 2.20.1