Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp832619pxu; Mon, 23 Nov 2020 05:26:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBqQ1WB5PulCPlMgdRjLeiYCLhxia1DHRAPxGVPVAtqg1RU6psLKGWtEC1iMad2MlHhIiq X-Received: by 2002:a05:6402:1c1c:: with SMTP id ck28mr14195289edb.336.1606137998512; Mon, 23 Nov 2020 05:26:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606137998; cv=none; d=google.com; s=arc-20160816; b=C4HrMWcdAFThQ80rh8KPZcR0GKI8plzxgtLXi5YOosPsKwby1xCJOwd8U8zTf7+kXQ Fil+I8hViKqZL+F0kAsAU+ElySOzxcEXpXmpb367hN0h7taVeL5skV6JjCSBAcfIBB73 Af/eN4bRvINhJ2JeybnmvlzcD7iQEZ6Ps0tEgMg8iOsPRRScnZ+5UWmEfDni5w8a1d31 Nycp0zDeQeBEau7S9LzuQlZi9SGYHtIV/AlBLn88X0+KK/c165oolTO/aKdRIyjAVqYh 3c2xFapJeVgmpvQ3QpfXsw7eH7zKtwvb7KFbajs01saAR/IWfQqPeDnvS88bPVLPQnNZ DEtw== 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=8MbEYtmOLsMleoAY/LoaAC6PZJRb4tZeuLc+lTl8qVQ=; b=fEfvG11qHumiJGN/bGiA5Hw088Ld5LNoQo+yA3j6W15RsdGVlk7ENG3qWZLAjn4bkY 8Xok+XyvWi0W2yy35wguWuX0FRTAJhwi/DA7a6YwWASzrCqe21IqkfCE1yVJllE+hwhX 5AKifGL4UEjci/y/jyrsWqmOeA851V2aOKdW351e/NUiQPMiqgEtC1xrkjWtr7vi5uO0 rTF3rjo9tp0Eg1JZroiE+86PJk8hocdJQfPkbN/ViLtLDkq97snmNkaRVeWatAeGOgyg ziHvd4+5zToRU3gSAabWgQ4jhSR8hsTLGMYNmK2UJcHnzQGBgCuTWW/cNtmlvPYuNxZ5 ImZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=GmJPvBfJ; 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 y4si6725925edv.83.2020.11.23.05.26.15; Mon, 23 Nov 2020 05:26:38 -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=GmJPvBfJ; 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 S1731892AbgKWMhP (ORCPT + 99 others); Mon, 23 Nov 2020 07:37:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:49236 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731883AbgKWMhI (ORCPT ); Mon, 23 Nov 2020 07:37:08 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 069C32065E; Mon, 23 Nov 2020 12:37:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606135028; bh=wDQ+6gq8lu/THGFYd719e9zdFYhFd8OvRz97iK/S3hA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GmJPvBfJyeL6wPZvw9Ub7W0m/3o7TkLp3lQO0ItNoKVDNX9pRPYJ3z2s3T03dwhVq TUq25pSFQ5UEg7QHLaUAfxOYmxN//9ytfa8JcJmf7MCVaqOWlKwXlIee4eN5WqbgcE 0T7sVViHGqZpXSu6qv2oYttI94lCgS5ELzT9nVFA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhang Qilong , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.4 078/158] can: ti_hecc: Fix memleak in ti_hecc_probe Date: Mon, 23 Nov 2020 13:21:46 +0100 Message-Id: <20201123121823.701897783@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121819.943135899@linuxfoundation.org> References: <20201123121819.943135899@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: Zhang Qilong [ Upstream commit 7968c7c79d3be8987feb8021f0c46e6866831408 ] In the error handling, we should goto the probe_exit_candev to free ndev to prevent memory leak. Fixes: dabf54dd1c63 ("can: ti_hecc: Convert TI HECC driver to DT only driver") Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201114111708.3465543-1-zhangqilong3@huawei.com Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/ti_hecc.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/can/ti_hecc.c b/drivers/net/can/ti_hecc.c index d3a7631eecaf2..d0a05fc5cc32f 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -873,7 +873,8 @@ static int ti_hecc_probe(struct platform_device *pdev) priv->base = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->base)) { dev_err(&pdev->dev, "hecc ioremap failed\n"); - return PTR_ERR(priv->base); + err = PTR_ERR(priv->base); + goto probe_exit_candev; } /* handle hecc-ram memory */ @@ -886,7 +887,8 @@ static int ti_hecc_probe(struct platform_device *pdev) priv->hecc_ram = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->hecc_ram)) { dev_err(&pdev->dev, "hecc-ram ioremap failed\n"); - return PTR_ERR(priv->hecc_ram); + err = PTR_ERR(priv->hecc_ram); + goto probe_exit_candev; } /* handle mbx memory */ @@ -899,13 +901,14 @@ static int ti_hecc_probe(struct platform_device *pdev) priv->mbx = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(priv->mbx)) { dev_err(&pdev->dev, "mbx ioremap failed\n"); - return PTR_ERR(priv->mbx); + err = PTR_ERR(priv->mbx); + goto probe_exit_candev; } irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!irq) { dev_err(&pdev->dev, "No irq resource\n"); - goto probe_exit; + goto probe_exit_candev; } priv->ndev = ndev; @@ -969,7 +972,7 @@ probe_exit_release_clk: clk_put(priv->clk); probe_exit_candev: free_candev(ndev); -probe_exit: + return err; } -- 2.27.0