[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <008dfc6bc5edb802f759227111f5a0eff153e279.1639066954.git.xhao@linux.alibaba.com>
Date: Fri, 10 Dec 2021 00:33:16 +0800
From: Xin Hao <xhao@...ux.alibaba.com>
To: sj@...nel.org
Cc: xhao@...ux.alibaba.com, akpm@...ux-foundation.org,
linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: [PATCH V1 1/2] mm/damon/dbgfs: Avoid target_ids display wrong pid value
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@...ux.alibaba.com>
---
mm/damon/dbgfs.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
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;
--
2.31.0
Powered by blists - more mailing lists