All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lukasz Majewski <lukma@denx.de>
To: Niel Fourie <lusus@denx.de>
Cc: u-boot@lists.denx.de, Ramon Fried <rfried.dev@gmail.com>,
	Marek Vasut <marex@denx.de>
Subject: Re: [PATCH] net: eth-uclass: change state before stop() in eth_halt()
Date: Thu, 1 Dec 2022 09:24:14 +0100	[thread overview]
Message-ID: <20221201092414.765944d9@wsk> (raw)
In-Reply-To: <20221130164225.766877-1-lusus@denx.de>

[-- Attachment #1: Type: text/plain, Size: 1650 bytes --]

On Wed, 30 Nov 2022 17:42:25 +0100
Niel Fourie <lusus@denx.de> wrote:

> In eth_halt(), change the private uclass state before calling
> stop() instead of afterwards, to avoid writing to memory which
> may have been freed during stop().
> 
> In the ethernet gadget implementation, the gadget device gets
> probed during start() and removed during stop(), which includes
> freeing `uclass_priv_` to which `priv` is pointing. Writing to
> `priv` after stop() may corrupt the `fd` member of `struct
> malloc_chunk`, which represents the freed block, and could cause
> hard-to-debug crashes on subsequent calls to malloc()/free().
> 
> Signed-off-by: Niel Fourie <lusus@denx.de>
> Cc: Ramon Fried <rfried.dev@gmail.com>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Lukasz Majewski <lukma@denx.de>
> ---
>  net/eth-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> index f41da4b37b3..bc3b9751e32 100644
> --- a/net/eth-uclass.c
> +++ b/net/eth-uclass.c
> @@ -342,9 +342,9 @@ void eth_halt(void)
>  	if (!priv || !priv->running)
>  		return;
>  
> -	eth_get_ops(current)->stop(current);
>  	priv->state = ETH_STATE_PASSIVE;
>  	priv->running = false;
> +	eth_get_ops(current)->stop(current);
>  }
>  
>  int eth_is_active(struct udevice *dev)

Reviewed-by: Lukasz Majewski <lukma@denx.de>


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2022-12-01  8:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 16:42 [PATCH] net: eth-uclass: change state before stop() in eth_halt() Niel Fourie
2022-12-01  8:24 ` Lukasz Majewski [this message]
2022-12-01 10:44   ` Marek Vasut
2022-12-02 10:36     ` Niel Fourie
2022-12-03 23:50       ` Ramon Fried
2022-12-04  2:20         ` Marek Vasut
2022-12-04  2:17       ` Marek Vasut
2022-12-05 12:06         ` Niel Fourie
2022-12-05 15:33           ` Niel Fourie
2022-12-05 16:20             ` Marek Vasut
2022-12-05 16:18           ` Marek Vasut

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=20221201092414.765944d9@wsk \
    --to=lukma@denx.de \
    --cc=lusus@denx.de \
    --cc=marex@denx.de \
    --cc=rfried.dev@gmail.com \
    --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 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.