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]
Date:	Fri, 25 Sep 2015 17:15:43 +0200
From:	Thierry Reding <thierry.reding@...il.com>
To:	Jani Nikula <jani.nikula@...ux.intel.com>
Cc:	dri-devel@...ts.freedesktop.org,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/6] driver-core: platform: Provide helpers for
 multi-driver modules

On Fri, Sep 25, 2015 at 01:27:28PM +0300, Jani Nikula wrote:
> On Thu, 24 Sep 2015, Thierry Reding <thierry.reding@...il.com> wrote:
[...]
> > diff --git a/drivers/base/platform.c b/drivers/base/platform.c
[...]
> > +/**
> > + * platform_register_drivers - register an array of platform drivers
> > + * @drivers: an array of drivers to register
> > + * @count: the number of drivers to register
> > + *
> > + * Registers platform drivers specified by an array. On failure to register a
> > + * driver, all previously registered drivers will be unregistered. Callers of
> > + * this API should use platform_unregister_drivers() to unregister drivers in
> > + * the reverse order.
> > + *
> > + * Returns: 0 on success or a negative error code on failure.
> > + */
> > +int platform_register_drivers(struct platform_driver * const *drivers,
> > +			      unsigned int count)
> > +{
> > +	unsigned int i;
> > +	int err;
> > +
> > +	for (i = 0; i < count; i++) {
> > +		pr_debug("registering platform driver %ps\n", drivers[i]);
> > +
> > +		err = platform_driver_register(drivers[i]);
> > +		if (err < 0) {
> > +			pr_err("failed to register platform driver %ps: %d\n",
> > +			       drivers[i], err);
> > +			goto error;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +
> > +error:
> > +	while (i--) {
> > +		pr_debug("unregistering platform driver %ps\n", drivers[i]);
> > +		platform_driver_unregister(drivers[i]);
> > +	}
> 
> This will call platform_driver_unregister() on the driver that failed,
> but not the first driver.
> 
> You should probably make i an int, and use while (--i >= 0).

Actually it won't. I was especially careful and even tested this with
one driver by instrumenting platform_driver_register() to return failure
at various points in the sequence.

This works fine.

Thierry

Download attachment "signature.asc" of type "application/pgp-signature" (820 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ