diff mbox series

[V1,1/2] mm/damon/dbgfs: Avoid target_ids display wrong pid value

Message ID 008dfc6bc5edb802f759227111f5a0eff153e279.1639066954.git.xhao@linux.alibaba.com (mailing list archive)
State New
Headers show
Series mm/damon: Do little changes | expand

Commit Message

haoxin Dec. 9, 2021, 4:33 p.m. UTC
The return value of pid_vnr() is pid_t type which is defined by 'int', this may
get a wrong pid value, if we set the return value type as 'unsigned long'.
So there fix it.

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
 mm/damon/dbgfs.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index 991b7fa0e858..97eebfb70ddf 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -281,17 +281,15 @@  static inline bool targetid_is_pid(const struct damon_ctx *ctx)
 static ssize_t sprint_target_ids(struct damon_ctx *ctx, char *buf, ssize_t len)
 {
 	struct damon_target *t;
-	unsigned long id;
-	int written = 0;
+	int id, written = 0;
 	int rc;
 
 	damon_for_each_target(t, ctx) {
-		id = t->id;
 		if (targetid_is_pid(ctx))
 			/* Show pid numbers to debugfs users */
-			id = (unsigned long)pid_vnr((struct pid *)id);
+			id = (int)pid_vnr((struct pid *)t->id);
 
-		rc = scnprintf(&buf[written], len - written, "%lu ", id);
+		rc = scnprintf(&buf[written], len - written, "%d ", id);
 		if (!rc)
 			return -ENOMEM;
 		written += rc;