Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1462862img; Tue, 26 Feb 2019 23:00:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IY6enBbcYK3p/7H8MTE2SzIxSDt3RMcVfyqHFeu7keF1FhrbcoeYw+3VKrpXWKfw9uiqqVn X-Received: by 2002:a63:1cd:: with SMTP id 196mr1605134pgb.58.1551250849759; Tue, 26 Feb 2019 23:00:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551250849; cv=none; d=google.com; s=arc-20160816; b=KGhtHJjnoH3XMOUNHZxmGq3ZwQ/K4CReU/GlYKeJS313MtXUudI+RpTFcJ/MovYZpu b3OfThOqoicASwRpaKij0nz9uRO9/9oec+NmJbEF1kcF/piQbd6lG/D83gWQ9ijFvrPF 7Hdvu8SRr8ZzAraKyVDyrjcE+Vb9LSR3YBZV6udz21UpkFQpdmu/Ua9QMJ705Gcl/0R4 vnNnL3cNel1JuD/k0lwQv0P0hqjG/jNVOVVbaGyImNrZOrXI/5G1mUL4phIIAFJ4TpsQ +a48SntuYHnooJ+CFio0OUPsLJ7REeBaa6HUiZTgHklXmZRCgC7ZksqMoPNCxWYy/BEV opGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=AtETILAsZKca4jNT3bz1CDdnKyArO352OR28Fygfh4Y=; b=x7SzNJyw+tZEKqtvniuAHIoadqNDh8kQwKEFIjHVULW6aBvxdgaVRPy7eI6jzv/6Yi QwSfq0GYpuhZlMbUEBW5iDzbwtwiu9zCyx9N0BPndv/Mu88hqbhPC1r4xXFU1bFpzcws 4LhX3qEsE4dLqW2spmErS9tylirRZoKi9j+tBZjhN0bIC3IQOBfVAJOsqosrzYDDL+Gt KneKV2MjSPBUipmySHkF8OxgDkVL3CZ+XqbRMNT8R0irBRZ8Z5sxul17RRI6FRwFmP2I LA2kL/rwdnb/Q7Ri/Y08hKkJiJiFSD5OwoPg46aDo7/++A8E3S6guNSA08QqHgMYvEVD WNQQ== ARC-Authentication-Results: i=1; mx.google.com; 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 l71si12998951pgd.529.2019.02.26.23.00.34; Tue, 26 Feb 2019 23:00:49 -0800 (PST) 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; 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 S1729629AbfB0HAE (ORCPT + 99 others); Wed, 27 Feb 2019 02:00:04 -0500 Received: from relmlor1.renesas.com ([210.160.252.171]:4044 "EHLO relmlie5.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726931AbfB0HAE (ORCPT ); Wed, 27 Feb 2019 02:00:04 -0500 X-IronPort-AV: E=Sophos;i="5.58,418,1544454000"; d="scan'208";a="8979692" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 27 Feb 2019 16:00:02 +0900 Received: from localhost.localdomain (unknown [10.166.252.89]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 525144031DA5; Wed, 27 Feb 2019 16:00:02 +0900 (JST) From: Yoshihiro Shimoda To: kishon@ti.com Cc: julia.lawall@lip6.fr, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH] phy: renesas: rcar-gen2: Fix memory leak at error paths Date: Wed, 27 Feb 2019 16:00:26 +0900 Message-Id: <1551250826-10302-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch fixes memory leak at error paths of the probe function. In for_each_child_of_node, if the loop returns, the driver should call of_put_node() before returns. Reported-by: Julia Lawall Fixes: 1233f59f745 ("phy: Renesas R-Car Gen2 PHY driver") Signed-off-by: Yoshihiro Shimoda --- drivers/phy/renesas/phy-rcar-gen2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c index 72eeb06..570b4e4 100644 --- a/drivers/phy/renesas/phy-rcar-gen2.c +++ b/drivers/phy/renesas/phy-rcar-gen2.c @@ -285,6 +285,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) error = of_property_read_u32(np, "reg", &channel_num); if (error || channel_num > 2) { dev_err(dev, "Invalid \"reg\" property\n"); + of_node_put(np); return error; } channel->select_mask = select_mask[channel_num]; @@ -300,6 +301,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev) &rcar_gen2_phy_ops); if (IS_ERR(phy->phy)) { dev_err(dev, "Failed to create PHY\n"); + of_node_put(np); return PTR_ERR(phy->phy); } phy_set_drvdata(phy->phy, phy); -- 2.7.4