From patchwork Wed Jul 18 16:10:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartosz Golaszewski X-Patchwork-Id: 10532781 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 42C7D601D2 for ; Wed, 18 Jul 2018 16:11:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3430925EF7 for ; Wed, 18 Jul 2018 16:11:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 27E072996F; Wed, 18 Jul 2018 16:11:10 +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 CCE7225EF7 for ; Wed, 18 Jul 2018 16:11:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731584AbeGRQtX (ORCPT ); Wed, 18 Jul 2018 12:49:23 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:56122 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731546AbeGRQtW (ORCPT ); Wed, 18 Jul 2018 12:49:22 -0400 Received: by mail-wm0-f66.google.com with SMTP id f21-v6so3338309wmc.5 for ; Wed, 18 Jul 2018 09:10:47 -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=EirWCWel/w1jaSio88cM+pYKnpg1qeQaHBKU4yixNfc=; b=EHtJuWoO8ddLvvPcVimKtHq6H8FCzhnH+7pzF5jw6GaqcXYVULCbQvQoyIn5ASUyEm f7zDWC1QrVN92CcoQW57/gEo0uIRrlNSgjl6n0hRexuov7WOocKC1Fsi4g+s+ZOL5n9T x1FeKQIU2dJuVrK86D0Gf+TK6S3Kpq2bWh4NpwmZDQV5+5d1FzUiLYZo83fVWqi1Oaf0 zqmmGgn7yTu/xMdApC0AIDaBQn8k+pSar5skAgB4lzqTgdlFxQLdNLfldfINYhgp/ZWZ WhuqQUdLp5TRmP+6JAOU/I6o2o+NfvgObBZVHLDVsc4URiyW8BtTsdT7rfDrKzcsKdj4 NTJg== 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=EirWCWel/w1jaSio88cM+pYKnpg1qeQaHBKU4yixNfc=; b=U1kgFmK3EfBKmwzbw9mhKZsFG5mjCugHZq2htLdsqb7Ja3QeilkO/Fqbj8Sw6M/yK3 jS1z2qmNLstyJlacHZew4cYouy44uPpaF0W5q0vx/SXQqJbVITvfXV/PAd3IKI/nr6Am lIaWbzF81Iu0E8jvG0raXGlyZJrnrzH08ufe8XVSObXrBsGq8Zu1P38bO2ssnVAcy19r 8Kqz8yHjyekldn9ZUM1um90gLR2j41vzAooJ3RT2KMVh2nETH1VZZyttOU3p65cHA5Fz r+JIA7a780yYoleWk6hEAPP3asca9yRp86Dq1vwoLhua1FfZ6/gdoI2alZrmn36rik35 Er8g== X-Gm-Message-State: AOUpUlFcHoVfrtINxUqvNn/78roP+iTX/W6ReahNs+65rPJiBSax2YBU 60QxjGVCPGZqDkzcUjxgbYimnw== X-Google-Smtp-Source: AAOMgpewbp5hFl5y/IcWNm7naKQjwy1bkB0Rq1kdgYVfhvYPX6gC55U0SsVOv5KPlyS0WjNzpFYBDQ== X-Received: by 2002:a1c:369c:: with SMTP id y28-v6mr1923561wmh.34.1531930246398; Wed, 18 Jul 2018 09:10:46 -0700 (PDT) Received: from brgl-bgdev.home ([2a01:cb1d:af:5b00:e837:b8d5:48c1:571b]) by smtp.gmail.com with ESMTPSA id v185-v6sm2847803wme.30.2018.07.18.09.10.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Jul 2018 09:10:45 -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 3/5] net: fortify eth_platform_get_mac_address() Date: Wed, 18 Jul 2018 18:10:33 +0200 Message-Id: <20180718161035.7005-4-brgl@bgdev.pl> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180718161035.7005-1-brgl@bgdev.pl> References: <20180718161035.7005-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 2a2173324d9e..6b64586fd2af 100644 --- a/net/ethernet/eth.c +++ b/net/ethernet/eth.c @@ -544,7 +544,7 @@ int eth_platform_get_mac_address(struct device *dev, u8 *mac_addr) from = "arch callback"; } - if (!addr) + if (!addr || !is_valid_ether_addr(addr)) return -ENODEV; dev_info(dev, "read MAC address from %s\n", from);