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] [day] [month] [year] [list]
Message-ID: <2025041532-sappiness-rental-e7e2@gregkh>
Date: Tue, 15 Apr 2025 18:01:38 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Salah Triki <salah.triki@...il.com>
Cc: Jim Cromie <jim.cromie@...il.com>, Arnd Bergmann <arnd@...db.de>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers: char: scx200_gpio: check return value of
 cdev_add()

On Tue, Apr 15, 2025 at 04:30:08PM +0100, Salah Triki wrote:
> On Tue, Apr 15, 2025 at 04:54:38PM +0200, Greg Kroah-Hartman wrote:
> > On Mon, Apr 07, 2025 at 05:56:14PM +0100, Salah Triki wrote:
> > > Check return value of cdev_add() and in case of error unregister the
> > > range of device numbers.
> > > 
> > > Signed-off-by: Salah Triki <salah.triki@...il.com>
> > > ---
> > >  drivers/char/scx200_gpio.c | 6 +++++-
> > >  1 file changed, 5 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/drivers/char/scx200_gpio.c b/drivers/char/scx200_gpio.c
> > > index 700e6affea6f..36efcc828e8e 100644
> > > --- a/drivers/char/scx200_gpio.c
> > > +++ b/drivers/char/scx200_gpio.c
> > > @@ -107,10 +107,14 @@ static int __init scx200_gpio_init(void)
> > >  	}
> > >  
> > >  	cdev_init(&scx200_gpio_cdev, &scx200_gpio_fileops);
> > > -	cdev_add(&scx200_gpio_cdev, devid, MAX_PINS);
> > > +	rc = cdev_add(&scx200_gpio_cdev, devid, MAX_PINS);
> > > +	if (rc)
> > > +		goto unregister_chrdev_region;
> > >  
> > >  	return 0; /* succeed */
> > >  
> > > +unregister_chrdev_region:
> > > +	unregister_chrdev_region(devid, MAX_PINS);
> > >  undo_platform_device_add:
> > >  	platform_device_del(pdev);
> > >  undo_malloc:
> > > -- 
> > > 2.43.0
> > > 
> > 
> > How was this tested?
> > 
> 
> I only compiled it.

Please properly test it.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ