All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benedikt Spranger <b.spranger@linutronix.de>
To: Roger Quadros <rogerq@kernel.org>
Cc: netdev@vger.kernel.org, MD Danish Anwar <danishanwar@ti.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Subject: Re: [PATCH] net: ti: icssg-prueth: Check return value to avoid a kernel oops
Date: Sun, 23 Mar 2025 16:18:26 +0100	[thread overview]
Message-ID: <20250323161826.5bcd9cf8@mitra> (raw)
In-Reply-To: <89f81b99-b505-48ad-b717-99e5d4d8e87b@kernel.org>

On Sun, 23 Mar 2025 09:19:35 +0200
Roger Quadros <rogerq@kernel.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

  reply	other threads:[~2025-03-23 15:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-22 14:33 [PATCH] net: ti: icssg-prueth: Check return value to avoid a kernel oops Benedikt Spranger
2025-03-23  7:19 ` Roger Quadros
2025-03-23 15:18   ` Benedikt Spranger [this message]
2025-03-24 14:44     ` Roger Quadros
2025-03-25 10:46       ` Benedikt Spranger

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=20250323161826.5bcd9cf8@mitra \
    --to=b.spranger@linutronix.de \
    --cc=andrew+netdev@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=rogerq@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.