On Thu, 29 Nov 2007, Kay Sievers wrote:Let's say device_register() calls device_init(), which calls kobject_init(), which fails. Then there's no cleanup to do -- device_register() returns -ENOMEM or some such code and the caller has to do the kfree(). Now let's say device_register() calls device_init(), which succeeds, and then calls device_add(), which fails. To recover properly, somebody then has to call device_put(). That "somebody" can't be the original caller -- according to the previous paragraph the original caller won't do anything but kfree(). So the "somebody" has to be device_register() itself. But the device_put() will call kobject_put(), which will invoke the device's cleanup routine, which will deallocate the structure. Now the original caller gets an error code (perhaps -ENOMEM again) but must _not_ call kfree(). So what should the original caller do when an error occurs? Alan Stern -
| Andrew Morton | -mm merge plans for 2.6.23 |
| Greg Kroah-Hartman | [PATCH 025/196] paride: Convert from class_device to device for block/paride |
| Renato S. Yamane | Error -71 on device descriptor read/all |
| Bart Van Assche | Integration of SCST in the mainstream Linux kernel |
git: | |
| David Miller | Re: [GIT]: Networking |
| Gerrit Renker | [PATCH 31/37] dccp: Remove manual influence on NDP Count feature |
| Frans Pop | svc: failed to register lockdv1 RPC service (errno 97). |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
