From patchwork Mon Jan 2 12:12:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 13086728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A465FC3DA7A for ; Mon, 2 Jan 2023 12:09:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=eN4iN0HOQKgVxyqSsFXEU6a3GjZEE0CLg5hT/7x/Me4=; b=lNls613RCWJdEk G7r6RJU6W5AunoEIZ3qFi7WQHV0peIasdTKF/YWQPEQPkPmGEalfB57QtncOU4dP7XTNHyYSXS58O d/k7XbgzjfDkPBRmDRPUZUoOhcdWjvjoFBIFWv963No4rGJ84eWAYW2adJ4uBaV8dnURPbifBi9rf MB/nBwnFy+PF1s3BV32X/dZsBDZE2rkzYIXh8ejSqsYiVDUn2z/rjngDth0rnVgo8e6dnK16HGtOu y3xtI8TIswZ/aDLMSlSN3YuZ7cWXtBRjdD6IZHQpmXpGWMJgju0LOdBj0BQMlmeamM5tfx1s23dkX yRq6Nwy66mP7kulAaHQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCJbn-00B7d0-Kr; Mon, 02 Jan 2023 12:08:03 +0000 Received: from esa.microchip.iphmx.com ([68.232.154.123]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCJba-00B7T3-S6 for linux-arm-kernel@lists.infradead.org; Mon, 02 Jan 2023 12:07:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1672661270; x=1704197270; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=oKV7nJa9FoGLOtU9V1hKIe38BFhTsWvOW7No+LXT7tQ=; b=qAY/fKlFm4EviTGKic3beO+/cAakjhMWPi3eTRgsPzxYSmCng9l3aZmR d3LZa6qfB19+dYC82fSwJtKDW16zRW3XXKQJGL4bWto2ZGGfZHnZj9bpt xgFX0XWipc9AXR9udqO3n7wff3FAGBozQAAwIFu36nKGEtuDt1VSILMcA B/eDzFH3jVOpN5HPEWSNtTukvZdmzvs1c0ZlGMD8viG/1ExirhRheRcvw 3ju5/PuELND+6OuVE/kbpoVL7eYDVQkjmJ2/aDKouM5OJrXrer9QE9AUm qH9V0z+U/3FPd+CWNe1NjQRJnsHWFmG5JB6I91i4bVtgx2zfiLsTiBBLd g==; X-IronPort-AV: E=Sophos;i="5.96,294,1665471600"; d="scan'208";a="130430292" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 02 Jan 2023 05:07:43 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Mon, 2 Jan 2023 05:07:41 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Mon, 2 Jan 2023 05:07:38 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , , , Horatiu Vultur Subject: [PATCH net] net: sparx5: Fix reading of the MAC address Date: Mon, 2 Jan 2023 13:12:15 +0100 Message-ID: <20230102121215.2697179-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230102_040751_056446_CAC2B61E X-CRM114-Status: GOOD ( 14.30 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There is an issue with the checking of the return value of 'of_get_mac_address', which returns 0 on success and negative value on failure. The driver interpretated the result the opposite way. Therefore if there was a MAC address defined in the DT, then the driver was generating a random MAC address otherwise it would use address 0. Fix this by checking correctly the return value of 'of_get_mac_address' Fixes: b74ef9f9cb91 ("net: sparx5: Do not use mac_addr uninitialized in mchp_sparx5_probe()") Signed-off-by: Horatiu Vultur --- drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c index d25f4f09faa06..3c5d4fe993737 100644 --- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c @@ -834,7 +834,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev) if (err) goto cleanup_config; - if (!of_get_mac_address(np, sparx5->base_mac)) { + if (of_get_mac_address(np, sparx5->base_mac)) { dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n"); eth_random_addr(sparx5->base_mac); sparx5->base_mac[5] = 0;