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. > > Sorry for the inconvenience again. > It's easy enough for fix this... Although instead of calling list_add_tail() and then list_del() I probably would have prefered to move the list_add_tail() right before the "return 0;" - list_add_tail(&rc->node, &rd->component_list); rc->dev.class = &raid_class.class; if (err) goto err_out; + list_add_tail(&rc->node, &rd->component_list); return 0; But the diff I sent you is the more conservative option. regards, dan carpenter diff --git a/drivers/scsi/raid_class.c b/drivers/scsi/raid_class.c index 711252e52d8e..86ed1f66d749 100644 --- a/drivers/scsi/raid_class.c +++ b/drivers/scsi/raid_class.c @@ -248,11 +248,9 @@ int raid_component_add(struct raid_template *r,struct device *raid_dev, return 0; err_out: - put_device(&rc->dev); list_del(&rc->node); rd->component_count--; - put_device(component_dev); - kfree(rc); + put_device(&rc->dev); return err; } EXPORT_SYMBOL(raid_component_add);