Revert "kernfs: fix memleak in kernel_ops_readdir()"

This reverts commit cc798c8389.

Tony writes:
	Somehow this causes a regression in Linux next for me where I'm
	seeing lots of sysfs entries now missing under
	/sys/bus/platform/devices.

	For example, I now only see one .serial entry show up in sysfs.
	Things work again if I revert commit cc798c8389 ("kernfs: fix
	memleak inkernel_ops_readdir()"). Any ideas why that would be?

Tejun says:
	Ugh, you're right.  It can get double-put cuz ctx->pos is put by
	release too.

So reverting it for now.

Reported-by: Tony Lindgren <tony@atomide.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Fixes: cc798c8389 ("kernfs: fix memleak in kernel_ops_readdir()")
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Greg Kroah-Hartman 2019-08-08 08:39:35 +02:00
Родитель cc798c8389
Коммит 8097c43bcb
1 изменённых файлов: 2 добавлений и 5 удалений

Просмотреть файл

@ -1684,14 +1684,11 @@ static int kernfs_fop_readdir(struct file *file, struct dir_context *ctx)
kernfs_get(pos); kernfs_get(pos);
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
if (unlikely(!dir_emit(ctx, name, len, ino, type))) { if (!dir_emit(ctx, name, len, ino, type))
kernfs_put(pos); return 0;
goto out;
}
mutex_lock(&kernfs_mutex); mutex_lock(&kernfs_mutex);
} }
mutex_unlock(&kernfs_mutex); mutex_unlock(&kernfs_mutex);
out:
file->private_data = NULL; file->private_data = NULL;
ctx->pos = INT_MAX; ctx->pos = INT_MAX;
return 0; return 0;