Skip to contentSkip to conversation

mm/damon/sysfs: remove repeat container_of() in damon_sysfs_kdamond_release()

PATCH Applied Xin Hao 2 participants 2 messages Mar 3, 2022

Subsystems (2)
lore
Share & tools
lore

Xin Hao

author
#0 lore raw

PATCH 1/1 mm/damon/sysfs: remove repeat container_of() in damon_sysfs_kdamond_release()

In damon_sysfs_kdamond_release(), we have use container_of() to get "kdamond" pointer, so there no need to get it once again.

---
 mm/damon/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/sysfs.c +1 -1
index a4ad6b473b0a..687e7c7e8dea 100644
@@ -2432,7 +2432,7 @@ static void damon_sysfs_kdamond_release(struct kobject *kobj)
 
 	if (kdamond->damon_ctx)
 		damon_destroy_ctx(kdamond->damon_ctx);
-	kfree(container_of(kobj, struct damon_sysfs_kdamond, kobj));
+	kfree(kdamond);
 }
 
 static struct kobj_attribute damon_sysfs_kdamond_state_attr =
Signature · 1 line
2.27.0
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Xin,

Quoted 2 lines · On Thu, 3 Mar 2022 15:53:14 +0800 Xin Hao <[email protected]> wrote:

In damon_sysfs_kdamond_release(), we have use container_of() to get "kdamond" pointer, so there no need to get it once again.

Good catch! Thank you always :)

Quoted 2 lines

Thanks,
SJ

Quoted 19 lines
---
 mm/damon/sysfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/sysfs.c +1 -1
index a4ad6b473b0a..687e7c7e8dea 100644
@@ -2432,7 +2432,7 @@ static void damon_sysfs_kdamond_release(struct kobject *kobj)
 
 	if (kdamond->damon_ctx)
 		damon_destroy_ctx(kdamond->damon_ctx);
-	kfree(container_of(kobj, struct damon_sysfs_kdamond, kobj));
+	kfree(kdamond);
 }
 
 static struct kobj_attribute damon_sysfs_kdamond_state_attr =
Signature · 1 line
2.27.0