lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f5ac3d3331bcd2403df33be05e0b928cf38c35dd.camel@esd.eu>
Date: Fri, 15 Aug 2025 15:02:19 +0000
From: Stefan Mätje <stefan.maetje@....eu>
To: "mkl@...gutronix.de" <mkl@...gutronix.de>
CC: "mailhol@...nel.org" <mailhol@...nel.org>, "socketcan@...tkopp.net"
	<socketcan@...tkopp.net>, "linux-can@...r.kernel.org"
	<linux-can@...r.kernel.org>, socketcan <socketcan@....eu>, Frank Jungclaus
	<frank.jungclaus@....eu>, "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"horms@...nel.org" <horms@...nel.org>, "olivier@...rie.be"
	<olivier@...rie.be>
Subject: Re: [PATCH 1/6] can: esd_usb: Fix possible calls to kfree() with NULL

Am Mittwoch, dem 13.08.2025 um 11:20 +0200 schrieb Marc Kleine-Budde:
> On 11.08.2025 23:06:06, Stefan Mätje wrote:
> > In esd_usb_start() kfree() is called with the msg variable even if the
> > allocation of *msg failed.
> > 
> > Move the kfree() call to a line before the allocation error exit label
> > out: and adjust the exits for other errors to the new free_msg: label
> > just before kfree().
> > 
> > In esd_usb_probe() add free_dev: label and skip calling kfree() if
> > allocation of *msg failed.
> > 
> > Fixes: fae37f81fdf3 ( "net: can: esd_usb2: Do not do dma on the stack" )
> > Signed-off-by: Stefan Mätje <stefan.maetje@....eu>
> > ---
> >  drivers/net/can/usb/esd_usb.c | 16 +++++++++-------
> >  1 file changed, 9 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
> > index 27a3818885c2..05ed664cf59d 100644
> > --- a/drivers/net/can/usb/esd_usb.c
> > +++ b/drivers/net/can/usb/esd_usb.c
> > @@ -3,7 +3,7 @@
> >   * CAN driver for esd electronics gmbh CAN-USB/2, CAN-USB/3 and CAN-USB/Micro
> >   *
> >   * Copyright (C) 2010-2012 esd electronic system design gmbh, Matthias Fuchs <socketcan@....eu>
> > - * Copyright (C) 2022-2024 esd electronics gmbh, Frank Jungclaus <frank.jungclaus@....eu>
> > + * Copyright (C) 2022-2025 esd electronics gmbh, Frank Jungclaus <frank.jungclaus@....eu>
> >   */
> >  
> >  #include <linux/can.h>
> > @@ -746,21 +746,22 @@ static int esd_usb_start(struct esd_usb_net_priv *priv)
> 
> 	msg = kmalloc(sizeof(*msg), GFP_KERNEL);
> 	if (!msg) {
> 		err = -ENOMEM;
> 		goto out;
> 	}
> 
> Can you adjust the jump label for the kmalloc() fail. There's no need to
> check for -ENODEV

Yes, I will move it in the next iteration. Thanks for that hint.

> Marc
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ