[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250323161826.5bcd9cf8@mitra>
Date: Sun, 23 Mar 2025 16:18:26 +0100
From: Benedikt Spranger <b.spranger@...utronix.de>
To: Roger Quadros <rogerq@...nel.org>
Cc: netdev@...r.kernel.org, MD Danish Anwar <danishanwar@...com>, Andrew
Lunn <andrew+netdev@...n.ch>
Subject: Re: [PATCH] net: ti: icssg-prueth: Check return value to avoid a
kernel oops
On Sun, 23 Mar 2025 09:19:35 +0200
Roger Quadros <rogerq@...nel.org> wrote:
> Did you actually get a kernel oops?
Yes. And I would like to attach the kernel output, but I do not have
access to the board ATM.
> If yes, which part of code produces the oops.
I get an NULL pointer dereference in is_multicast_ether_addr().
It happens here:
u32 a = *(const u32 *)addr;
> Even if it fails we do set a random MAC address and do not return
> error. So above statement is false.
I doubt that. of_get_ethdev_address() do not set a random MAC address
in case of a failure. It simply returns -ENODEV. Since
is_valid_ether_addr() fails with a NULL pointer dereference in
is_multicast_ether_addr() on the other hand, no random MAC address is
set.
> > Check the return value of of_get_ethdev_address() before validating
> > the MAC address.
>
> If of_get_ethdev_address() fails the netdev address will remain zero
> (as it was zero initialized during allocation) so
> is_valid_ether_addr() will fail as well.
Yes. It will fail to. But is_valid_ether_addr() is not called any more.
Due to the if statement is_valid_ether_addr() is only called, if
of_get_ethdev_address() exits with 0 aka success. In case of a failure
the if statement is true and there is no call to is_valid_ether_addr().
Regards
Bene
Powered by blists - more mailing lists