Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1062684ybl; Wed, 14 Aug 2019 10:06:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNNrF7mKdcDrqdaDikLiG2R3kHg0ip/xYwUzGJb9YKiARhHVlK6R3q9rWDlCnqKdKTPscm X-Received: by 2002:a62:e910:: with SMTP id j16mr978127pfh.123.1565802409751; Wed, 14 Aug 2019 10:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565802409; cv=none; d=google.com; s=arc-20160816; b=vX/2D2ro76prw/uxtDw5cSoBXVN8CDMwa2RhnvWjKqbcmM6iB4VVdLBtLArBFb/X3X 6toKscrhdt4cARxYiiIs4PBVV5VlS5/AbkegdGeaYBoWB7tCRK9Jm6sCOP8RKZ+7+FZt oYj5Zcs6DrlF6aWZ65QfEwB2CL5EOgDFWXe5FRetwcq3BR7wQxdvjQ7EiPgA6CRaeXQ/ zFL8BPbpIch8KWyYrHNpD3V5698l47TcgsCmtCJM9u6Tfq5md6/25mB7blcDwok5LuTN UpgHDbFxqn34pUasSvaGwvJG3/kHMMvzhdn7su1rQaIWCx2rrD9LXrLZpcJtfXZxl8HF 174Q== 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=K+nrnldk8LQjxYb4OOJSNyZLENHx625lOvAwpUiMpjs=; b=NxfR7hAwc5GmQjJbRYv/xoho1Pw9lCYnf0qK4uXI1ThdqBtfYaBX4a+/xJZ7YbrBoe K6GkWxlSF/k1akqE/qZHtg5BsefigsNRccOwt3iI05u3B3RoerhHMXkSJpAPn04gypDk Lajl7Yw71cLj3jcObG9LELd9anQXPuean1/TbDobchb5PRS9zQ0cPE0JvuaA+t4Gz1B2 i825YsPa4Sm8hfgK15H4baFTrMXXZIb3hg1r9BTGnFZv3InDfNr0evfZbQudHEkINw8j TYHJjU7BhE/sBubXFdW+rp2iZplIsA8SJTev9NYnZP1RVluek6mnyOJQFfVgPCjGD6SE wtTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lkQ1Ny3d; 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 61si189353plb.270.2019.08.14.10.06.33; Wed, 14 Aug 2019 10:06:49 -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=lkQ1Ny3d; 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 S1729096AbfHNREB (ORCPT + 99 others); Wed, 14 Aug 2019 13:04:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:52736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729089AbfHNRD7 (ORCPT ); Wed, 14 Aug 2019 13:03:59 -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 9638621721; Wed, 14 Aug 2019 17:03:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565802238; bh=z+Yin1l0uC3EEV8udrsuSZXDzBL1PiKwdzmYceVqWxk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lkQ1Ny3dNjFRL5yKJsA+Z4dgLf0CfItJZv5iFoXUdLDLjOguTjPJcHtRXDz6zAmXR tqfZWdHcE5FJJt0NHq010F5FToqUFZQdcWTeiM0wWUH4CEMeSYPOggrT+mglgDAeNu CcFLL3vexFq3kJMw6YADd6ga7+dOqVOkFWtKSJqc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Wen Yang , Marc Kleine-Budde Subject: [PATCH 5.2 047/144] can: flexcan: fix an use-after-free in flexcan_setup_stop_mode() Date: Wed, 14 Aug 2019 19:00:03 +0200 Message-Id: <20190814165801.795811337@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190814165759.466811854@linuxfoundation.org> References: <20190814165759.466811854@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 From: Wen Yang commit e9f2a856e102fa27715b94bcc2240f686536d29b upstream. The gpr_np variable is still being used in dev_dbg() after the of_node_put() call, which may result in use-after-free. Fixes: de3578c198c6 ("can: flexcan: add self wakeup support") Signed-off-by: Wen Yang Cc: linux-stable # >= v5.0 Signed-off-by: Marc Kleine-Budde Signed-off-by: Greg Kroah-Hartman --- drivers/net/can/flexcan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -1455,10 +1455,10 @@ static int flexcan_setup_stop_mode(struc priv = netdev_priv(dev); priv->stm.gpr = syscon_node_to_regmap(gpr_np); - of_node_put(gpr_np); if (IS_ERR(priv->stm.gpr)) { dev_dbg(&pdev->dev, "could not find gpr regmap\n"); - return PTR_ERR(priv->stm.gpr); + ret = PTR_ERR(priv->stm.gpr); + goto out_put_node; } priv->stm.req_gpr = out_val[1]; @@ -1473,7 +1473,9 @@ static int flexcan_setup_stop_mode(struc device_set_wakeup_capable(&pdev->dev, true); - return 0; +out_put_node: + of_node_put(gpr_np); + return ret; } static const struct of_device_id flexcan_of_match[] = {