Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1898667yba; Fri, 10 May 2019 03:01:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqy83D7L04TbFEVkNkIrRmt9qXR1cBkx39R2ki3JOjXf4vjMJS0eSfsXgiWZsgWi5mZIvaIH X-Received: by 2002:a63:9214:: with SMTP id o20mr12339144pgd.203.1557482467273; Fri, 10 May 2019 03:01:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557482467; cv=none; d=google.com; s=arc-20160816; b=fRtloyD+zv1dsyD6TSQWGqTS428uEE4RiUlvE5g3N8MAwZwG6XQI+ew4QmhxW7FWRq YtcFtW1Ptb/h4b/kM+afhmc0H2+Pb4d1k/u7XCt3sajtjsySVv2N76uGve5iFAbKzEWC pdp9qHymv6sAD5TDGgeQtgUZMd6BEj0ZDVaj2WVyWQjA5GcZ4hl+sZUpli1QWmuWBdCL sTqLikMJ4tRoiihkL4+80nPRfVo/j6utm40nIChq7N4TFDKybIqDn8DUxfJYYG/U7ke9 KnJ2+Iz3z37pSlnJuSFK1ygojC0NaiNIkqGZKRiBiZfEGQLOoGcGJHUqg1459fHbC+I4 44wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=iT75btHuy5yhg5RfE7Ztt9kM0YMVqrRVuVq4JWP/Tc4=; b=ZDkBGc3Kx73eUF5Z1efyNF7Qy2B1FeaVe+tdCenVlFMqiU4uhWBk6vafcKJDKv6z7Z M1b90pFkFwJque/I7pgs9+PLSImuA8Tc240PisOg4Gm4L6myYbIJhF/d3tdxJqSvnJNH USH1afEah4YPKPrbmKKjXPAIbFEptCj4jR/Z6vpQjclS/WRDh5xP/fIz3Jt2SolkeuU3 ihMpOiJPphq1xKTf0B4DuSr/Nl9//coxgN1JI1JKQM0DZvlAlLWr8X0lNK7kcLzoa+dn CpOw8y7voLPe28WB61EzXP2jsPW2yFLmY95+9FEaRKeNMJbQ3vyFOgu8pe9AJrca8OM8 PPzA== 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 p2si7004188pgj.138.2019.05.10.03.00.48; Fri, 10 May 2019 03:01:07 -0700 (PDT) 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 S1727348AbfEJJfs (ORCPT + 99 others); Fri, 10 May 2019 05:35:48 -0400 Received: from smtp-out.xnet.cz ([178.217.244.18]:32964 "EHLO smtp-out.xnet.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727097AbfEJJfr (ORCPT ); Fri, 10 May 2019 05:35:47 -0400 Received: from meh.true.cz (meh.true.cz [108.61.167.218]) (Authenticated sender: petr@true.cz) by smtp-out.xnet.cz (Postfix) with ESMTPSA id 01B2D4347; Fri, 10 May 2019 11:35:43 +0200 (CEST) Received: by meh.true.cz (OpenSMTPD) with ESMTP id 9913a3c0; Fri, 10 May 2019 11:35:42 +0200 (CEST) From: =?UTF-8?q?Petr=20=C5=A0tetiar?= To: netdev@vger.kernel.org, Andrew Lunn , Florian Fainelli , Heiner Kallweit , Rob Herring , Frank Rowand Cc: Rob Herring , =?UTF-8?q?Petr=20=C5=A0tetiar?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net 1/5] of_net: remove nvmem-mac-address property Date: Fri, 10 May 2019 11:35:14 +0200 Message-Id: <1557480918-9627-2-git-send-email-ynezz@true.cz> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1557480918-9627-1-git-send-email-ynezz@true.cz> References: <1557480918-9627-1-git-send-email-ynezz@true.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In commit d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") I've added `nvmem-mac-address` property which was wrong idea as I've allocated the property with devm_kzalloc and then added it to DT, so then 2 entities would be refcounting the allocation. So if the driver unbinds, the buffer is freed, but DT code would be still referencing that memory. I'm removing this property completely instead of fixing it, as it's not needed to have it. Fixes: d01f449c008a ("of_net: add NVMEM support to of_get_mac_address") Suggested-by: Rob Herring Signed-off-by: Petr Štetiar --- drivers/of/of_net.c | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) diff --git a/drivers/of/of_net.c b/drivers/of/of_net.c index 9649cd53e955..a4b392a5406b 100644 --- a/drivers/of/of_net.c +++ b/drivers/of/of_net.c @@ -52,39 +52,22 @@ static const void *of_get_mac_addr(struct device_node *np, const char *name) static const void *of_get_mac_addr_nvmem(struct device_node *np) { int ret; - u8 mac[ETH_ALEN]; - struct property *pp; + const void *mac; + u8 nvmem_mac[ETH_ALEN]; struct platform_device *pdev = of_find_device_by_node(np); if (!pdev) return ERR_PTR(-ENODEV); - ret = nvmem_get_mac_address(&pdev->dev, &mac); + ret = nvmem_get_mac_address(&pdev->dev, &nvmem_mac); if (ret) return ERR_PTR(ret); - pp = devm_kzalloc(&pdev->dev, sizeof(*pp), GFP_KERNEL); - if (!pp) + mac = devm_kmemdup(&pdev->dev, nvmem_mac, ETH_ALEN, GFP_KERNEL); + if (!mac) return ERR_PTR(-ENOMEM); - pp->name = "nvmem-mac-address"; - pp->length = ETH_ALEN; - pp->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL); - if (!pp->value) { - ret = -ENOMEM; - goto free; - } - - ret = of_add_property(np, pp); - if (ret) - goto free; - - return pp->value; -free: - devm_kfree(&pdev->dev, pp->value); - devm_kfree(&pdev->dev, pp); - - return ERR_PTR(ret); + return mac; } /** -- 1.9.1