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: 13086727 X-Patchwork-Delegate: kuba@kernel.org 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D81CBC3DA7A for ; Mon, 2 Jan 2023 12:07:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232471AbjABMHq (ORCPT ); Mon, 2 Jan 2023 07:07:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230196AbjABMHp (ORCPT ); Mon, 2 Jan 2023 07:07:45 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D748F5FFB; Mon, 2 Jan 2023 04:07:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1672661264; x=1704197264; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=oKV7nJa9FoGLOtU9V1hKIe38BFhTsWvOW7No+LXT7tQ=; b=ROaUk1zPxsCBGzczcWLoneWYCEkMi+1dGac2UuMsEVNCYDlyfv40SB7s gdsz6awHmYEy93+Srvdb7KoNgZdV+59gq7+wMwqInkmDvLEXF2b3Emo/F 18pN97rXm/iaW3XLCZxcsj1G/7XBG8VVUdhEtV/MU5YGa0WW9e5G7mz5m 37mDByV0duV8Tj2EZKwIOw375pvIaDqPRFBouUHRheqELMLhnS1gWiCDs 9z5bdNdWU3K/75w9Ais1U2T0gJ/Y2K5dKtKSQJ/XL5m88T3ehPZNBup6v DfkAsMuymCI+FXEKhQou2xAyMMRCviAfoDVFX/DPvaB9XGbNEfK2jmOR9 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 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.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;