Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1797462rwb; Thu, 10 Nov 2022 23:58:17 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Fj6ViTD5RX5fwWSRXrwKwfk+plSDSuJL6AOHT3tUQVzePfGvM05GCGSTQIW357JuUHlXq X-Received: by 2002:a17:906:e8f:b0:78d:3cdb:e7ee with SMTP id p15-20020a1709060e8f00b0078d3cdbe7eemr1009794ejf.134.1668153497270; Thu, 10 Nov 2022 23:58:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668153497; cv=none; d=google.com; s=arc-20160816; b=mY7W2Zehh/2TFzR8sWrTnV4z8M865FiZXAzQglAi0iYIdmXg2p1yl6QXhGk9t+9QbJ 07dbswxzkNemXuHKd7K1nTBlPcEMpAkPWxoWtNntHK3kQnp4lV+0mIUmE0/8wIRkMvgc 7l0LvaPUu2sk8hiYazvZ1rzQ2+TWy6em1Z+8JxntqEGVkj5NvgcxcmfaWFl4JwqdWQrc 6PGrct0zPtUNS+lHc4OmePdiG3VoRzQV88EL6IpM7TgSyQKpuN1furucf0uaG5wGiuiC T2ZLMQWDhno/Gr/OXm1LcsSUUOZYYj69tzlEKt5GO+nvrK3dS7xKi/iqW/XHnHjJdd4g qTPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from; bh=43k/EOibONny7Ylxo/zWQk6HVg60hoYkg4dzMkX9YxA=; b=ovD6hM7djFLMOL5WP+QUyM/3Tl83X4U6FHLyrIOlVUwHwxgJSkg2Qcqs/+G1ugeSCe h1+le005vLuTKPkplCR1RYe+PViqq/eLYVgVmZOq2FJ0umRqpiyRLA43b4WUYWFoHXai q1WxkDXVHB/MGY7B/ZSgzfWk7vdu8iYuyZo5UKjWQu+UFqJJeDp57vblvBiPAI7z6/J4 lV1XLNS4N5TKJkT0TyrE4bK/IE1+CQDaCh07DxJ74Bhin6cu91ISbCGRTrmw9g9jQ41g q8zj2box1ZLZcKPTmM9i7b7jatDtEF7yF2edpt1sDZEnmp3a3uMQuvQwYz4JAL2LU2D9 gLxg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a16-20020aa7cf10000000b00461a98a20cbsi1448793edy.187.2022.11.10.23.57.55; Thu, 10 Nov 2022 23:58:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233159AbiKKHJp (ORCPT + 92 others); Fri, 11 Nov 2022 02:09:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbiKKHJn (ORCPT ); Fri, 11 Nov 2022 02:09:43 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B647918383; Thu, 10 Nov 2022 23:09:40 -0800 (PST) Received: from canpemm500006.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4N7qZJ5vkXzHvgZ; Fri, 11 Nov 2022 15:09:12 +0800 (CST) Received: from localhost.localdomain (10.175.104.82) by canpemm500006.china.huawei.com (7.192.105.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Fri, 11 Nov 2022 15:09:38 +0800 From: Ziyang Xuan To: , , , , , , , , Subject: [PATCH net 4/4] octeon_ep: ensure get mac address successfully before eth_hw_addr_set() Date: Fri, 11 Nov 2022 15:09:35 +0800 Message-ID: <223ee27c25cc506b8d49c87e8a95b06c6eb2b971.1668150074.git.william.xuanziyang@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.104.82] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To canpemm500006.china.huawei.com (7.192.105.130) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org octep_get_mac_addr() can fail because send mbox message failed. If this happens, octep_dev->mac_addr will be zero. It should not continue to initialize. Add exception handling for octep_get_mac_addr() to fix it. Fixes: 862cd659a6fb ("octeon_ep: Add driver framework and device initialization") Signed-off-by: Ziyang Xuan --- drivers/net/ethernet/marvell/octeon_ep/octep_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 53f288c32238..b45dd7f04e21 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1072,7 +1072,11 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) netdev->max_mtu = OCTEP_MAX_MTU; netdev->mtu = OCTEP_DEFAULT_MTU; - octep_get_mac_addr(octep_dev, octep_dev->mac_addr); + err = octep_get_mac_addr(octep_dev, octep_dev->mac_addr); + if (err) { + dev_err(&pdev->dev, "Failed to get mac address\n"); + goto register_dev_err; + } eth_hw_addr_set(netdev, octep_dev->mac_addr); err = register_netdev(netdev); -- 2.25.1