Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3706397pxb; Mon, 24 Jan 2022 15:55:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDe3F/DQBIlTIi0pzEobSSPi33bZm9xPhIxG+xbCkPpSnHZvHsmW0gDu8oUvuPWuQFOEr2 X-Received: by 2002:a63:9712:: with SMTP id n18mr13506505pge.594.1643068470832; Mon, 24 Jan 2022 15:54:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068470; cv=none; d=google.com; s=arc-20160816; b=ENxdWz/oYqbTyZ9XespruYwJ/apux397CuG0tiy0oSJFehEa6et3svNP5JV/nC0/cw /IgHtCq9Nqj7VlYlu5J82ekvJIcV9XGcxY4zBpiovKr3EC3WwI48VrjNwD4eQ9dz88fj uN9Gnmb5ZyB9ZmyUzNeyM6WS115XwmJUXtQEdPxvrX/fhuopZuWJz5kmfHFJUUklTZN/ 0vqPbmFB6Q9uboHhpXUv1kLmA21WR8YqFs32wIUzXK/xveX3AA/Dzfi447ZKIcmDkmRm dDWT0gHNPbslIETR5Upcf0BVp/TAvZc26Hkml/bmMwNsBUOGpW62M7Yi2w93qGzVwgoe kHIw== 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=oY/N09BOr4rtt+JEf3UWbSGT6sqjSARvVTCO2Qha3uE=; b=feujxWD0Dxa8a1+0zfjgTSP6shekna00VddROiMJnuGUdVtlTqU2jzm4MQkPYJZoNv AtweTKXYEZRCwGYc2N96GIaP0KeIqesGozh9xIpnlRd5EhvHtJD0G8xGOe9DJuhIMWak NZyfS7kIN1v19x+KDml7aVH0FSp00oiEUjQ5/tvw8BEGAWS8c0Q0HlCjNmfwBt1jmSX/ +pmV/eeuqPdqsLjV4wZc3SfoKGL7cN+mr9HuqphAtxCUD2JdB0hBXBWkkgHykp62+732 GsEivXHh0gla6Td600vIOYV8fn73riGK67BuF9Q0zF/mziWih+PwWq/MV7qQU/ztm36A viCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QpxPhhaj; 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 f24si11209877pgg.792.2022.01.24.15.54.19; Mon, 24 Jan 2022 15:54:30 -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=QpxPhhaj; 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 S2362956AbiAXXnO (ORCPT + 99 others); Mon, 24 Jan 2022 18:43:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1843478AbiAXXED (ORCPT ); Mon, 24 Jan 2022 18:04:03 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1CDCC061A7C; Mon, 24 Jan 2022 13:14:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5EB7CB811FB; Mon, 24 Jan 2022 21:14:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89FC5C340E5; Mon, 24 Jan 2022 21:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058893; bh=14/r+hbS3Go8S3OHeRGpUygNx3H7+e9c8m+YWqIr+MA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpxPhhaj+AbaTHGnTkM0/ARnXPAZMGZr3kMiKpGSBAdLJtNM+khj0gS8fS3U9AIei uS5QP+BOU1JkXajajtC+DvXMu2Tqf5dTyzR4DL6qTszOuJ4R313pi4XEg37wgCNLJc 1Vj5xN77RURn6gkGaQNPcbKOAjqSRXmKxuGR2RS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Lad Prabhakar , Kieran Bingham , Marc Kleine-Budde , Sasha Levin Subject: [PATCH 5.16 0435/1039] can: rcar_canfd: rcar_canfd_channel_probe(): make sure we free CAN network device Date: Mon, 24 Jan 2022 19:37:04 +0100 Message-Id: <20220124184139.921784434@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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: Lad Prabhakar [ Upstream commit 72b1e360572f9fa7d08ee554f1da29abce23f288 ] Make sure we free CAN network device in the error path. There are several jumps to fail label after allocating the CAN network device successfully. This patch places the free_candev() under fail label so that in failure path a jump to fail label frees the CAN network device. Fixes: 76e9353a80e9 ("can: rcar_canfd: Add support for RZ/G2L family") Link: https://lore.kernel.org/all/20220106114801.20563-1-prabhakar.mahadev-lad.rj@bp.renesas.com Reported-by: Pavel Machek Signed-off-by: Lad Prabhakar Reviewed-by: Kieran Bingham Signed-off-by: Marc Kleine-Budde Signed-off-by: Sasha Levin --- drivers/net/can/rcar/rcar_canfd.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c index ff9d0f5ae0dd2..388521e70837f 100644 --- a/drivers/net/can/rcar/rcar_canfd.c +++ b/drivers/net/can/rcar/rcar_canfd.c @@ -1640,8 +1640,7 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, ndev = alloc_candev(sizeof(*priv), RCANFD_FIFO_DEPTH); if (!ndev) { dev_err(&pdev->dev, "alloc_candev() failed\n"); - err = -ENOMEM; - goto fail; + return -ENOMEM; } priv = netdev_priv(ndev); @@ -1735,8 +1734,8 @@ static int rcar_canfd_channel_probe(struct rcar_canfd_global *gpriv, u32 ch, fail_candev: netif_napi_del(&priv->napi); - free_candev(ndev); fail: + free_candev(ndev); return err; } -- 2.34.1