@@ -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;
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(-)