From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] phy: Fix u-boot coruption when fixed-phy is used
Date: Thu, 20 Dec 2018 14:13:03 +0100 [thread overview]
Message-ID: <e166be4f-6bbd-09fe-b051-3badadb34ecc@denx.de> (raw)
In-Reply-To: <6a39ed60e60f94be2af9577f88214033fdabcd40.1545235056.git.michal.simek@xilinx.com>
On 19.12.18 16:57, Michal Simek wrote:
> When fixed-link phy is used subnode offset is used as phy address. This
> number is bigger then space allocated for bus structure (allocated via
> mdio_alloc).
> bus->phymap[] array has PHY_MAX_ADDR size (32).
> That's why writing bus->phymap[addr] where addr is < 0 or > PHY_MAX_ADDR
> is causing write to memory which can caused full U-Boot crash.
>
> The patch is checking if address is in correct range.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> search_for_existing_phy() is using this array but there is if check
> already that's why it shouldn't be a big deal.
>
> ---
> drivers/net/phy/phy.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index e837eb7688cc..cda4caa8034d 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -656,7 +656,8 @@ static struct phy_device *phy_device_create(struct mii_dev *bus, int addr,
>
> phy_probe(dev);
>
> - bus->phymap[addr] = dev;
> + if (addr >= 0 && addr < PHY_MAX_ADDR)
> + bus->phymap[addr] = dev;
How about adding some error / warning print in the else path here?
Thanks,
Stefan
next prev parent reply other threads:[~2018-12-20 13:13 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-19 15:57 [U-Boot] [PATCH] phy: Fix u-boot coruption when fixed-phy is used Michal Simek
2018-12-20 13:13 ` Stefan Roese [this message]
2018-12-21 7:40 ` Michal Simek
2018-12-27 15:47 ` [U-Boot] " Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e166be4f-6bbd-09fe-b051-3badadb34ecc@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox