lkml.org 
[lkml]   [2021]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH V2 3/4] zram: avoid race between zram_remove and disksize_store
On Wed, Oct 20, 2021 at 09:55:47AM +0800, Ming Lei wrote:
> After resetting device in zram_remove(), disksize_store still may come and
> allocate resources again before deleting gendisk, fix the race by resetting
> zram after del_gendisk() returns. At that time, disksize_store can't come
> any more.
>
> Reported-by: Luis Chamberlain <mcgrof@kernel.org>
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> drivers/block/zram/zram_drv.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index 8883de7aa3d7..6078d1dae44a 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -2002,6 +2002,13 @@ static int zram_remove(struct zram *zram)
> /* del_gendisk drains pending reset_store */
> WARN_ON_ONCE(claimed && zram->claim);
>
> + /*
> + * disksize store may come between zram_reset_device and del_gendisk, so
> + * run the last reset for avoiding leak anything allocated in
> + * disksize_store().

The above is not clear English, how about:

disksize_store() may be called in between zram_reset_device() and
del_gendisk(), so run the last reset to avoid leaking anything allocated
with disksize_store()

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>

Luis

\
 
 \ /
  Last update: 2021-10-22 21:04    [W:0.154 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site