On 8/10/23 05:26, Dan Carpenter wrote:
On Thu, Aug 10, 2023 at 08:05:21PM +0800, wangzhu wrote:
Hello Dan Carpenter:
Sorry for the patch 04b5b5cb0136 I submitted, I thought put_dev(&rc->dev) is
not the same as kfree(rc).
Then should I submit a revert patch again, or you can fix it yourself?
please let me know what I can do.
The original code was buggy and the new code is slightly buggier.
Instead of reverting, lets see if anyone knows the correct way to fix
this. If no one comments within a week then I agree that reverting is
better than a double free.
The standard solution is to have two error paths: one error path that
cleans up the actions performed before device_add() and a second error
path with a put_device() call in case device_add() fails. See e.g.
sd_probe().
Bart.