Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp1426268img; Tue, 26 Feb 2019 22:09:32 -0800 (PST) X-Google-Smtp-Source: AHgI3IY23ahTqd4eRQIfMvKbMPIutLW3qyAqC1f3DHimV9J6Ibc+DTM4HKRyAFj1oCGl8X9IfSJX X-Received: by 2002:a17:902:42e:: with SMTP id 43mr474788ple.88.1551247772489; Tue, 26 Feb 2019 22:09:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551247772; cv=none; d=google.com; s=arc-20160816; b=PBy4oOkk7WMeNtA0UePSFfvJtHd7eD8gBAkrnEVPKDwnaGOcqBNC/y5Mt55aaQ+3Yq XUQ/GFZi/8b2JBIsVr6wc3/FDjTszrvX3t6O9EJJKPuLidIHKLQCzWx9lqUNXr/y0bLK yI9YiHWnkpHmMcKe34LZC0rLjCdWEfM0/Wh/ARb4A/N+zLT0azJu8txELeEZh+gOVYbK lY5W4lLuydDinJjcfWUvD9rUnhNH0XzMLuwDyv8lpA1bEF6/gn0QKAZzjKU7uzRenEQG q0//qeJU8aY1NSInudv27zs/xyQJclp7tQhZnRHurSIWUdFx0PIKQ7X7uck9hnZofadb 0rAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=u4lmChDYFE+Rz9HSMNMyiHWEi+XYjNjqTt6iqts1kDs=; b=bkrqtdFur+jisjqGL2y7mQiCUDKQaEpdgFeVQf8QLbYCtvtQ59UKojmmhNrUXwhLIz krnWPA7Mb/dFipXB2PUS1biN7+wOZgulLNfokXZYgw7pfRAPAAq/VGUwFt8QO/lg2X3j HVkeRLAGwHo7MVwpQtYHESzhYPhkmWCJhCx3X7zFTlfgwvo4Lnado0hkNGe3X+X64oC2 cmbT/oaEmqK9/QiwrFmJ6ZxNAVW65P+dJNg96f8g7R2BgQCAbV92s+w90HSgXquPsztm rR7uFfGlN49F9HH69qb2S2t+VyG25rR8zrOZqPpaBvIMhzg/zAMnDooE6uufyMZs5QEg x49A== 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 c11si8858640pga.350.2019.02.26.22.09.15; Tue, 26 Feb 2019 22:09:32 -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 S1729592AbfB0GIY (ORCPT + 99 others); Wed, 27 Feb 2019 01:08:24 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:17368 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbfB0GIY (ORCPT ); Wed, 27 Feb 2019 01:08:24 -0500 X-IronPort-AV: E=Sophos;i="5.58,418,1544482800"; d="scan'208";a="297446552" Received: from abo-58-107-68.mrs.modulonet.fr (HELO hadrien) ([85.68.107.58]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Feb 2019 07:08:21 +0100 Date: Wed, 27 Feb 2019 07:08:20 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Yoshihiro Shimoda cc: "linux-kernel@vger.kernel.org" , Kishon Vijay Abraham I , "Sergei Shtylyov (sergei.shtylyov@cogentembedded.com)" Subject: RE: question about drivers/phy/renesas/phy-rcar-gen2.c In-Reply-To: Message-ID: References: User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 27 Feb 2019, Yoshihiro Shimoda wrote: > Hello, > > > From: Julia Lawall, Sent: Tuesday, February 26, 2019 6:01 PM > > > > On Tue, 26 Feb 2019, Yoshihiro Shimoda wrote: > > > > > Hello, > > > (Sergei made this code, so I added his email as CC) > > > > > > I'm sorry for the delayed response. > > > > > > > From: Julia Lawall, Sent: Sunday, February 3, 2019 4:03 PM > > > > > > > > Hello, > > > > > > > > I was wondering whether phy-rcar-gen2.c would use dynamically allocated > > > > device nodes? > > > > > > I'm sorry, but what is "dynamically allocated device nodes"? > > > > Device nodes for which there will be a meor leak if one doesn't put > > of_node_put. > > Thank you. I understood it. > > > julia > > > > > > > > Best regards, > > > Yoshihiro Shimoda > > > > > > > If so, it looks like the following code could cause a > > > > use-after-free, due to not incrementing th reference count: > > > > > > > > for_each_child_of_node(dev->of_node, np) { > > > > struct rcar_gen2_channel *channel = drv->channels + i; > > > > u32 channel_num; > > > > int error, n; > > > > > > > > channel->of_node = np; > > IIUC, since the channel->of_node will be used for comparing the pointer > in rcar_gen2_phy_xlate(), it is not use-after-free. > However, the for_each_child_of_node() in rcar_gen2_phy_probe() will return > without of_put_node() at error paths. So, I'll submit a bugfix patch later. > > Thank you very much for your report! Thanks for taking care of it. julia > > Best regards, > Yoshihiro Shimoda > > > > > ... > > > > } > > > > > > > > On the other hand, if the reference cound it incrememnted, preventing > > > > memory leaks in the case where the probe function fails would entail some > > > > complex rewriting of the code, so I thought it would be better to ask > > > > first. > > > > > > > > thanks, > > > > julia > > > >