From patchwork Thu Jul 19 08:20:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10533791 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DE1F4600F4 for ; Thu, 19 Jul 2018 08:20:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB9882939B for ; Thu, 19 Jul 2018 08:20:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFB4B29438; Thu, 19 Jul 2018 08:20:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 708CD2939B for ; Thu, 19 Jul 2018 08:20:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731497AbeGSJCe (ORCPT ); Thu, 19 Jul 2018 05:02:34 -0400 Received: from mail-wr1-f48.google.com ([209.85.221.48]:37434 "EHLO mail-wr1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731213AbeGSJCd (ORCPT ); Thu, 19 Jul 2018 05:02:33 -0400 Received: by mail-wr1-f48.google.com with SMTP id q10-v6so7132718wrd.4 for ; Thu, 19 Jul 2018 01:20:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GD31JLCNt8L1SLxIII8ZY0h+x0qTpgVuq1EzBxuSJSA=; b=acXBfGRWXA+I7bgMj+okioJKnjvjKMxDAjJCYaxQ5hKnn/ipAd1NRzrxqxLV592499 1OrX01twt4O2CD/Y1Cim4696UHEG2VQPJodmSR/x1xSPbxQGRsXyTw1JwoKG81rC7PA+ HKHeezw90jdaxQ3lOg96we+jMUKeG/NvUmgcIdMR1u+vBBG7knHNEuMoAgx7REj3NuYX USu5QLc+6zKbdtAdyQu9dVWDN5NXC7BI26IpV6gwVMZ1qlG5PymO2QhUijbhsP7eZ7BL 6TqyLvytu7P5+nuc/julJ589qTcrRENnTCVzxUSqZaA5kKNIEOMlCvwOhymBbHgmWJOi 1vfg== 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:in-reply-to :references; bh=GD31JLCNt8L1SLxIII8ZY0h+x0qTpgVuq1EzBxuSJSA=; b=k2xYxfV+Y/0tVptFTEPsTtg/4O3+GftsQQUmQeECgUd8Q9l6uZSh00l5IPk3Ys9rqf 7PghNyuqGdGE5XDyVoh+cPujONyQfO92B+E5irbwG+GK6NYMUViMQ0jgVKDAmiXiBf20 g6nWGX0hzANvj1xbkkCRIay1xcIuePzvyGMqYSv6bSNaEhGKkX1LP2A+WhFDOpOeqO4V scVLgzc2on5qk4q4Hdv1TOOlSnkVQ8uCT2oPI3i5Tfw8zeTMXZUeEZYFQ/yzxAoLntUd n/5SmNAIVOxe3tG0/RXCUxNqDjHzY7ywXkYC55NDnA82yAihp96YMtp6BzTZWcIQd3a/ pwFA== X-Gm-Message-State: AOUpUlGtHKX7w/3Bi+DqNuncfgrf3tC8v0yXpU7nowTfPmF6/3JJPIWL s81DbUG3kDWr4JcexueqUpnGYw== X-Google-Smtp-Source: AAOMgpcEMk0FaEio3Fxu4SiPcEyScKHLARXxtXCIc2tdO5179xaxVdRsVG4LfiY1bp3vsF2Ej5zhyQ== X-Received: by 2002:adf:a0f3:: with SMTP id n48-v6mr6946521wrn.23.1531988433260; Thu, 19 Jul 2018 01:20:33 -0700 (PDT) Received: from brgl-bgdev.baylibre.local (AStLambert-681-1-40-185.w90-86.abo.wanadoo.fr. [90.86.159.185]) by smtp.gmail.com with ESMTPSA id h43-v6sm1716338wrh.1.2018.07.19.01.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Jul 2018 01:20:32 -0700 (PDT) From: Bartosz Golaszewski To: Sekhar Nori , Kevin Hilman , Russell King , Grygorii Strashko , "David S . Miller" , Srinivas Kandagatla , Lukas Wunner , Rob Herring , Florian Fainelli , Dan Carpenter , Ivan Khoronzhuk , David Lechner , Greg Kroah-Hartman , Andrew Lunn Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, netdev@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v2 1/3] net: fortify eth_platform_get_mac_address() Date: Thu, 19 Jul 2018 10:20:26 +0200 Message-Id: <20180719082028.26116-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180719082028.26116-1-brgl@bgdev.pl> References: <20180719082028.26116-1-brgl@bgdev.pl> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Bartosz Golaszewski We'll soon have more sources from which to read the MAC address in this routine. Make sure the address is correct before returning it. Signed-off-by: Bartosz Golaszewski Reviewed-by: Andrew Lunn --- net/ethernet/eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c index ee28440f57c5..39af03894598 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -541,7 +541,7 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) if (!addr) addr = arch_get_platform_mac_address(); - if (!addr) + if (!addr || !is_valid_ether_addr(addr)) return -ENODEV; ether_addr_copy(mac_addr, addr);