No, you must not use kfree() after you called device_register() (even
if it was not successful!) -- see the comment for device_register().
Yes, Your are right. First we need to call put_device() then kfree().
I will send updated patch.
No, that's not correct, either. device_register() will give up any
reference it obtained, and the caller did not obtain any additional
reference, so a put_device() would be wrong. A kfree() on a refcounted
structure is wrong as well.
No, you must not use kfree() after you called device_register() (even
if it was not successful!) -- see the comment for device_register().
Yes, Your are right. First we need to call put_device() then kfree().
I will send updated patch.
No, that's not correct, either. device_register() will give up any
reference it obtained, and the caller did not obtain any additional
reference, so a put_device() would be wrong. A kfree() on a refcounted
structure is wrong as well.
If you will see the comment for device_register() (drivers/base/core.c)
there is mentioned that
'NOTE: _Never_ directly free @dev after calling this function, even
if it returned an error! Always use put_device() to give up the
reference initialized in this function instead.'
But as per you comment. we should not use.
Thanks,
No, you must not use kfree() after you called device_register() (even
if it was not successful!) -- see the comment for device_register().
Yes, Your are right. First we need to call put_device() then kfree().
I will send updated patch.
No, that's not correct, either. device_register() will give up any
reference it obtained, and the caller did not obtain any additional
reference, so a put_device() would be wrong. A kfree() on a refcounted
structure is wrong as well.
If you will see the comment for device_register() (drivers/base/core.c)
there is mentioned that
'NOTE: _Never_ directly free @dev after calling this function, even
if it returned an error! Always use put_device() to give up the
reference initialized in this function instead.'
But as per you comment. we should not use.
Thanks,
In case that device_register() fails simply call device_put(). This will decrement
the last reference and then free the memory.
Regards,
Lino
No, you must not use kfree() after you called device_register() (even
if it was not successful!) -- see the comment for device_register().
Yes, Your are right. First we need to call put_device() then kfree().
I will send updated patch.
No, that's not correct, either. device_register() will give up any
reference it obtained, and the caller did not obtain any additional
reference, so a put_device() would be wrong. A kfree() on a refcounted
structure is wrong as well.
If you will see the comment for device_register() (drivers/base/core.c)
there is mentioned that
'NOTE: _Never_ directly free @dev after calling this function, even
if it returned an error! Always use put_device() to give up the
reference initialized in this function instead.'
But as per you comment. we should not use.
You don't need to do a put_device() after your device_unregister(),
that's all managed by the driver core.