From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4394DC43217 for ; Thu, 1 Dec 2022 08:24:24 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 06E23853F4; Thu, 1 Dec 2022 09:24:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1669883062; bh=tckt4H6t0gT4lCnBr/TsrS1/NA48POP2M1ALORSl+TY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=wH8GrQoDHwEaHqmFpWWGiYI3enE19KWpJScYVzQ0YDnBTB/7J16hU7h7vFOVI5lbE 8v2DdcmKqOnFMwDTjF8pB4t28yP5iEGTpIgVW3EfXa9D9LaMA1OVRtVZ4kHKFMiEQq 5BquF1aFsI9Kvi8jOR7veaTlNv4DECTzvDAr6Szy16OHFkwl0QaEsXcRJoZSuG98qO Um24MUW4WXXUPvEG4BxDTwzp0UmXvA8EGoDxMtAPeMLhYgTKwmNtZF7CYSaHI9pVfg bBNaWuvtfsblIEHOn2XOoAoBTTbgbtKzilpSWrd2TOt/NVY00+/Uf7JQ1nvkx+NZ2q Bb9Mah8+g0Mrg== Received: from wsk (85-222-111-42.dynamic.chello.pl [85.222.111.42]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: lukma@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 16E20853F1; Thu, 1 Dec 2022 09:24:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1669883061; bh=tckt4H6t0gT4lCnBr/TsrS1/NA48POP2M1ALORSl+TY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RR+zljWO6i8thTfC9zHQk8h143z4TVczGvi1dk1feMPvhCRG7kr0wua+Dzjl7KLOm yndiOxOYzxORMyU1TeC2OLIpnIa2jW9UvdTjamrUweAViEEcUPNq3gdEA0nePGWHk8 0S/efyAjTt3RJTzFeDT2+cafASd7bUHTQTcNdC45ea6Ij0vSnIoYO1xpA6XH6pIkgX TrWaL3kgmXG9+5SKAjej6leQDk5/lZR0DED6lD9U4jC9X9sCJKiKym8mSh03KAqFPr s724cQmuZnV55dOTxx/uspAFSAlgcGC4DrdFHdMYt2Ee997DdYr/VTmAEDKAARqyPj /Z9C+Ry2eXVGQ== Date: Thu, 1 Dec 2022 09:24:14 +0100 From: Lukasz Majewski To: Niel Fourie Cc: u-boot@lists.denx.de, Ramon Fried , Marek Vasut Subject: Re: [PATCH] net: eth-uclass: change state before stop() in eth_halt() Message-ID: <20221201092414.765944d9@wsk> In-Reply-To: <20221130164225.766877-1-lusus@denx.de> References: <20221130164225.766877-1-lusus@denx.de> Organization: denx.de X-Mailer: Claws Mail 3.19.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_//A1VH.XJ_x3llLmyAB6pLY="; protocol="application/pgp-signature"; micalg=pgp-sha512 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean --Sig_//A1VH.XJ_x3llLmyAB6pLY= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 30 Nov 2022 17:42:25 +0100 Niel Fourie 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(). >=20 > 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(). >=20 > Signed-off-by: Niel Fourie > Cc: Ramon Fried > Cc: Marek Vasut > Cc: Lukasz Majewski > --- > net/eth-uclass.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > 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; > =20 > - eth_get_ops(current)->stop(current); > priv->state =3D ETH_STATE_PASSIVE; > priv->running =3D false; > + eth_get_ops(current)->stop(current); > } > =20 > int eth_is_active(struct udevice *dev) Reviewed-by: Lukasz Majewski 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 --Sig_//A1VH.XJ_x3llLmyAB6pLY= Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEgAyFJ+N6uu6+XupJAR8vZIA0zr0FAmOIZK4ACgkQAR8vZIA0 zr2NjQgAslUkjrk5TfAfxfyJfbhvYBtEif8c0h3DKKUm0kaaJBhqhHwHh96mFlWs 4nTh5vz1DjC4jl5CVKrQw/Id19c77To/fTl7kAbcahGLTBMjgl45gqPQ78eDIa5+ gPB9S0JsZhQsjtbi1bngbUHyVPdtxsvSEL9XieG9jG4dwxFmGfd5OfVAnwoVU9eg rqxfOS21KK9SmLs9/uio1RmUtDNuGyo4Cyk7EuuLYtiRKTVEtOy+VGpgyF/YDRQR N43AGAVddbgQR00h7mEdZMJ1AQY8Oz1NWEzpU5KPajlyF1ZSgtWQiHHqNal22j+1 kZozwQprJ4DwZIS/fCog1m7BkcLw+A== =LqFY -----END PGP SIGNATURE----- --Sig_//A1VH.XJ_x3llLmyAB6pLY=--