Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp646631ybz; Wed, 29 Apr 2020 06:59:27 -0700 (PDT) X-Google-Smtp-Source: APiQypJLzUxAO0yprZgMu/TcaqpyibxMEtqmM5TrY9wWSD7tMFg8k4ug3fxVAWV7Uxg62WHGRy7+ X-Received: by 2002:a05:6402:1adc:: with SMTP id ba28mr2604843edb.12.1588168767573; Wed, 29 Apr 2020 06:59:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588168767; cv=none; d=google.com; s=arc-20160816; b=CW++r9JhNFC5egR+zyj7iP04WNCa8voP+D4z/S4Zy//c2mx753R/JyPnjO/E+BMu3h E1X7+PzdxijYw6PqOa+FBf4a4jJAfran2CQWxwETeTvZivDVd+Ic6a4Sh6tq/NTJeqMb Q4uLx/Dth9zr6dGEPablsOQg5Cu8ka/91RzsQlg9v7Fbg1uT83XdIsOFK6eCgcxmbXB/ cgS3iMUOyMQFgMJ8KZIiQR5YEfq9D2SDoWvDxLLS7pLhn9ZnMunPnvdMSniETaMyS2Mq qE2tH6yWC3nATdwG/TXHmQYVtQd5/SjjMC4b3NLnJBUFlhH6INkmwBCsp1ej5Y8TQP2O WjcA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=U2+xNJj7blIBAN27XYooXiQDtKXv0S4FTtN6zbBijtI=; b=yMaMgZ+xJLQmeNTESLBZoaCJ+k3ek9BqkHj+OQgjLS7f3Z4xa9AhejA37gGOZYXShV BEbWHeHluIyp2HZcQ1nIT0Ab5bXIu6rOakZTYt1+WTUJr315MtFZH8aAVN+lNLnCXRNL 2ZWkFVlHVgY71OPw2iF8ObTYH8W7LpBf/jHq3H/XI8lL+dSfyPik6Gk3I7NANIMC1/5p zb6/7fA7/lJFa0FqFX8VoyOhNP8llWd2k9lnheWYQ8KCyWFWw1g9nF34wO66NYJW5iYP rtb8lCZX5VqpgARfVjWHHp0maDczJ0N9344RemDOnZ3gJxfh98iwv26bdut180Yr80rd /OtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HUrMkgpK; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f25si3459587edw.292.2020.04.29.06.59.02; Wed, 29 Apr 2020 06:59:27 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=HUrMkgpK; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728044AbgD2N5A (ORCPT + 99 others); Wed, 29 Apr 2020 09:57:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727089AbgD2N47 (ORCPT ); Wed, 29 Apr 2020 09:56:59 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 785E9C03C1AD; Wed, 29 Apr 2020 06:56:59 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id h12so2341859pjz.1; Wed, 29 Apr 2020 06:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U2+xNJj7blIBAN27XYooXiQDtKXv0S4FTtN6zbBijtI=; b=HUrMkgpKn/ZQfsXraS+H1vmtx/FSvAbCf908nuuZ7ZDLAdtoWMU8EkzdzlU9JQ8QZu ANH8otGBqQl1q8UKJ2BjvOLrPE/YUkMH0q7UJYzSgGxKc2hXik53ixcLC5VWbrBfD14G 1Z1mu6ZdCWob82MPl0lnDmXBq9sobyEHrLjc7S+8hveoKPmNgzUjJYh4YYeJhGc6xlNr DMHFpsP3cMWgpeULqF22dvF6j5frUCp6jOHv6Fvk52H/DB/MTfJXqI/ZLKA0Xog92Ozu VUH5PIb0x3uZ1qJKdRPSMA65ZyjNRwWpOqydQknghkWfN8EQxcTd7wBF466HVIiqKwXL rxjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=U2+xNJj7blIBAN27XYooXiQDtKXv0S4FTtN6zbBijtI=; b=dNHqoIi0MKxZ1Yfx5u8jsRaAhS819pEOApvHDFzeVAvX+x5kqKI3eXjK1E6zzP0VdL jix5gzdhde1swZ/EA3r+e4uLZflnD5L+VSYobMJUqCPII6Do963QtmZbzSBVhUilyX7Q xFYiDVRJ5chCqDcNrzrt+EK/ckR1KHiZjbotOf5EcWIsvFnONIkMkAYEjMPZq3vwHULT DBpz8TUzIe9XLAQAS2yk6W1l/l1E5oapQpMZQdDxNvjsExrhX/pVW++T8B6R7Us2ekjf cpzejkMvj9oG7nBjKESh9vVZjix/UFwOa+iVL9wFoovuO0JvbtSj2YSa4tYgNDl2waDl Pb7w== X-Gm-Message-State: AGi0PuZt/Gd9cl63ftTk0fJBNjSuUf/BOlPat1F7Y59UxZMoG/jVsRI6 a1Hd6CYH236AL0wHGSv/Sj8= X-Received: by 2002:a17:902:8ec1:: with SMTP id x1mr33887861plo.180.1588168619043; Wed, 29 Apr 2020 06:56:59 -0700 (PDT) Received: from localhost ([89.208.244.169]) by smtp.gmail.com with ESMTPSA id y24sm1151342pfn.211.2020.04.29.06.56.57 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Apr 2020 06:56:58 -0700 (PDT) From: Dejin Zheng To: nicolas.ferre@microchip.com, davem@davemloft.net, paul.walmsley@sifive.com, palmer@dabbelt.com, yash.shah@sifive.com, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dejin Zheng , Andy Shevchenko Subject: [PATCH net v2] net: macb: fix an issue about leak related system resources Date: Wed, 29 Apr 2020 21:56:51 +0800 Message-Id: <20200429135651.32635-1-zhengdejin5@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A call of the function macb_init() can fail in the function fu540_c000_init. The related system resources were not released then. use devm_platform_ioremap_resource() to replace ioremap() to fix it. Fixes: c218ad559020ff9 ("macb: Add support for SiFive FU540-C000") Cc: Andy Shevchenko Reviewed-by: Yash Shah Signed-off-by: Dejin Zheng --- v1 -> v2: - Nicolas and Andy suggest use devm_platform_ioremap_resource() to repalce devm_ioremap() to fix this issue. Thanks Nicolas and Andy. - Yash help me to review this patch, Thanks Yash! drivers/net/ethernet/cadence/macb_main.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index a0e8c5bbabc0..99354e327d1f 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -4172,13 +4172,7 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk, static int fu540_c000_init(struct platform_device *pdev) { - struct resource *res; - - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (!res) - return -ENODEV; - - mgmt->reg = ioremap(res->start, resource_size(res)); + mgmt->reg = devm_platform_ioremap_resource(pdev, 1); if (!mgmt->reg) return -ENOMEM; -- 2.25.0