Re: [PATCH 21/38] workqueue: add missing put_device call

From: Tejun Heo
Date: Thu Dec 19 2013 - 10:45:29 EST


On Thu, Dec 19, 2013 at 10:42 AM, Levente Kurusa <levex@xxxxxxxxx> wrote:
>> Greg, the API as described by the comment is really weird and
>> unconventional. Failed calls are not supposed to have side effects
>> which require explicit cleanup. Can we please update the comment?
>>
>
> Yes, it was already discussed that it would be more sane to have
> device_register() call put_device() if it would fail, but Greg
> said that the API was designed so that no kfree()s happen in the core.

Of course not. For the third time: A failed call shouldn't make
material changes which makes difference to its caller. An obj which
failed init should be destructible in the exact reverse operation that
the caller took to create it. This is a fundamental rule of any API
design. There sure are occasional exceptions but there's no reason to
deviate from that here.

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/