[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180718164218.GD12477@lunn.ch>
Date: Wed, 18 Jul 2018 18:42:18 +0200
From: Andrew Lunn <andrew@...n.ch>
To: Bartosz Golaszewski <brgl@...ev.pl>
Cc: Sekhar Nori <nsekhar@...com>, Kevin Hilman <khilman@...nel.org>,
Russell King <linux@...linux.org.uk>,
Grygorii Strashko <grygorii.strashko@...com>,
"David S . Miller" <davem@...emloft.net>,
Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Lukas Wunner <lukas@...ner.de>, Rob Herring <robh@...nel.org>,
Florian Fainelli <f.fainelli@...il.com>,
Dan Carpenter <dan.carpenter@...cle.com>,
Ivan Khoronzhuk <ivan.khoronzhuk@...aro.org>,
David Lechner <david@...hnology.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-omap@...r.kernel.org, netdev@...r.kernel.org,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: Re: [PATCH 4/5] net: add support for nvmem to
eth_platform_get_mac_address()
> + if (!IS_ERR(nvmem)) {
> + addr = nvmem_cell_read(nvmem, &alen);
> + if (!IS_ERR(addr)) {
> + from = "nvmem";
> + /* Don't use ether_addr_copy() in case we
> + * didn't get the right size.
> + */
Please verify the size. A short read can still give a valid MAC
address, so the is_valid_ether_addr(addr) is not sufficient.
> + memcpy(addrbuf, addr, alen);
Another reason to check the length is that you appear to have a buffer
overflow here, if alen > 6.
Andrew
> + kfree(addr);
> + addr = addrbuf;
> + }
> +
> + nvmem_cell_put(nvmem);
> + }
> + }
> +
> if (!addr || !is_valid_ether_addr(addr))
> return -ENODEV;
>
> --
> 2.17.1
>
Powered by blists - more mailing lists