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:	Thu, 22 Nov 2007 00:52:30 +0000
From:	Russell King - ARM Linux <linux@....linux.org.uk>
To:	ian <spyro@....com>
Cc:	eric miao <eric.y.miao@...il.com>,
	Dmitry Baryshkov <dbaryshkov@...il.com>,
	ARM Linux <linux-arm-kernel@...ts.arm.linux.org.uk>,
	linux-kernel@...r.kernel.org
Subject: Re: [UPDATED PATCH] Support for Toshiba TMIO multifunction devices

On Thu, Nov 22, 2007 at 12:34:09AM +0000, ian wrote:
> +void mfd_free_devices(struct platform_device *devices, int nr_devs)
> +{
> +	struct platform_device *dev = devices;
> +	int i;
> +
> +	for (i = 0; i < nr_devs; i++) {
> +		struct resource *res = dev->resource;
> +		platform_device_unregister(dev++);
> +		kfree(res);
> +	}
> +	kfree(devices);
> +}
> +EXPORT_SYMBOL_GPL(mfd_free_devices);

Unfortunately, this is broken as designed (in fact this whole file is.)
I'm not sure why people just don't get it.  sysfs.  devices.  device tree.
It has object lifetime rules.  You can _not_ go around unregistering things
and then immediately freeing them - something else might _still_ be using
stuff even after the call to unregister returns.

It's a potential OOPS just waiting to happen.

That's why we have a proper management API for platform devices.  Please
use it, I didn't add the code for just for fun.

See platform_device_alloc() + platform_device_add_resources() +
platform_device_add_data() + platform_device_add() to create, and
platform_device_unregister() to destroy.

(Not looked at the rest because you really really need to get this
right first.)
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ