Re: [RFC 1/2] kobject_set_name - error handling

Dmitry Torokhov
2004-04-30T12:48:18Z

On Friday 30 April 2004 05:14 am, Maneesh Soni wrote:

> diff -puN drivers/base/bus.c~kobject_set_name-cleanup-01 drivers/base/bus.c
> --- linux-2.6.6-rc2-mm2/drivers/base/bus.c~kobject_set_name-cleanup-01 2004-04-30 15:14:03.000000000 +0530
> +++ linux-2.6.6-rc2-mm2-maneesh/drivers/base/bus.c 2004-04-30 15:14:03.000000000 +0530
> @@ -451,7 +451,9 @@ int bus_add_driver(struct device_driver
>
> if (bus) {
> pr_debug("bus %s: add driver %s\n",bus->name,drv->name);
> - kobject_set_name(&drv->kobj,drv->name);
> + error = kobject_set_name(&drv->kobj,drv->name);
> + if (error)
> + return error;

Hi, I think you are leaking a reference here, put_bus() is needed.

> drv->kobj.kset = &bus->drivers;
> if ((error = kobject_register(&drv->kobj))) {
> put_bus(bus);

--
Dmitry