Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp3389613lkq; Mon, 23 Nov 2020 04:35:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6D8GZk+TqR1FHOgLOccB3ZuamNAFEXJV0zbIHxewparwoSpb7oPk145hl7FtB4bwonCPE X-Received: by 2002:a17:906:8387:: with SMTP id p7mr41682187ejx.511.1606134919594; Mon, 23 Nov 2020 04:35:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606134919; cv=none; d=google.com; s=arc-20160816; b=umXkCwCKVZS41jjjOkswPvG0+3sVhJx7ZAqzjWxxd6IOdxFs9WCKHhh7Y1dNTsnAdg r8cJLJhUPwx4iJfmD/f0mj1QAkmqNyvTvAO3uYp22+Q0nMXkpe7DBMKUF2lAZ+fGnFqS 75o2HwgA9B5HRC8d1u+upvlKBv59EtaD56ZTG8L2+9e2FiI4atidxemiSoWgYB+yKIOy mAH4EJ9Okdanlyrh0ExESaQ4AjiVNJnGpwyPRt6Tk7Qn4Z2+4rBEA20M+TsdP8+61yXS LeA7WfqxkqgLrbk740Du2Uj2ofNh0n7xW1ekEGde2FREzVnFI0GiwamyOLnH13uPluqc 36eQ== 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=VKJwumkCNJ8AvvUmlWZYlIdkpLFgfdjlkwKakPCZNqY=; b=JdDX5PMNzQZ7znPvIJDXUYjT/gu3dsj3qaIxm6P7bcxj0DgOBAOfZt3nLH3UILGjfX WqRS4j3UmOE80vKrMCn9iTxLj2CH1bdzHwKPtMdU2+PYq6NgbLoOxs+z7RR9lQvLA/jT tny4WI10EOieS4nuBK1MOCE4GJ5U9lnsDqudLYBN2yYTWlVRFZJwgbH+IoGHFKrDpMC3 PgIPGcRE9pJsSo+j3MfcBSCkWkUFraYBgRFsI9BsN9sM3jDnIbG858LR+iAnj+FzdGZl ZNMuiX/m2kHdHHWeW99up9BELt2HZD6QcZEAZ7h5gaHEBZv5jaCu4o4/krD869QZfkEW aKVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="P+/mf+ks"; 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 gw26si2418949ejb.436.2020.11.23.04.34.56; Mon, 23 Nov 2020 04:35:19 -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="P+/mf+ks"; 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 S1731015AbgKWMcF (ORCPT + 99 others); Mon, 23 Nov 2020 07:32:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:42826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730889AbgKWMbj (ORCPT ); Mon, 23 Nov 2020 07:31:39 -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 81B522076E; Mon, 23 Nov 2020 12:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1606134699; bh=B0HIVhOOFgPqMRT5qB5gRrANqaf0nGkWUCvrnaJBgVg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P+/mf+ksN2cDc6fDHHCIFDJVFuYTP0Wu93kxnigaVZ8PIbze5gw7sCcn9RhIx3Jmo rRhsmxCKE90d2UUXx0p83oc7wkM4bD6vT+zqzbnIoXG1zFdNdwAckbZf/EXyOKl+Ae rxjUtvYX7G0UGxZH95z+bCLDVUewN3Obx1qaTqDc= 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 4.19 51/91] can: ti_hecc: Fix memleak in ti_hecc_probe Date: Mon, 23 Nov 2020 13:22:11 +0100 Message-Id: <20201123121811.803791718@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123121809.285416732@linuxfoundation.org> References: <20201123121809.285416732@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 db6ea936dc3fc..81a3fdd5e0103 100644 --- a/drivers/net/can/ti_hecc.c +++ b/drivers/net/can/ti_hecc.c @@ -903,7 +903,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 */ @@ -916,7 +917,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 */ @@ -929,13 +931,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; @@ -988,7 +991,7 @@ probe_exit_clk: clk_put(priv->clk); probe_exit_candev: free_candev(ndev); -probe_exit: + return err; } -- 2.27.0