Re: [PATCH] x86: mcheck: call put_device on device_register failure

From: Levente Kurusa
Date: Sat Nov 30 2013 - 02:31:06 EST


2013-11-29 21:56, Borislav Petkov:
> On Fri, Nov 29, 2013 at 09:28:48PM +0100, Levente Kurusa wrote:
>> This patch adds a call to put_device() when the device_register()
>> call has failed. This is required so that the last reference to the
>> device is given up.
>
> I'd assume this is not something you're actually hitting but have caught
> this by code staring...?
>

Yup, I have been staring at it.

> If we're going to do this, I'd also like to see you add another label
> after device_unregister(dev) which also kfrees dev because apparently
> we're not doing that either.
>

No, if the call to put_device gives up the last reference to the device,
then device_release gets called which in turn frees the memory associated with it.
In this case, mce_device_release() will get called, which is just a simple kfree call.

--
Regards,
Levente Kurusa
--
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/