Chenwandun f7daefe423 zram: fix race between backing_dev_show and backing_dev_store
CPU0:				       CPU1:
backing_dev_show		       backing_dev_store
    ......				   ......
    file = zram->backing_dev;
    down_read(&zram->init_lock);	   down_read(&zram->init_init_lock)
    file_path(file, ...);		   zram->backing_dev = backing_dev;
    up_read(&zram->init_lock);		   up_read(&zram->init_lock);

gets the value of zram->backing_dev too early in backing_dev_show, which
resultin the value being NULL at the beginning, and not NULL later.

backtrace:
  d_path+0xcc/0x174
  file_path+0x10/0x18
  backing_dev_show+0x40/0xb4
  dev_attr_show+0x20/0x54
  sysfs_kf_seq_show+0x9c/0x10c
  kernfs_seq_show+0x28/0x30
  seq_read+0x184/0x488
  kernfs_fop_read+0x5c/0x1a4
  __vfs_read+0x44/0x128
  vfs_read+0xa0/0x138
  SyS_read+0x54/0xb4

Link: http://lkml.kernel.org/r/1571046839-16814-1-git-send-email-chenwandun@huawei.com
Signed-off-by: Chenwandun <chenwandun@huawei.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: <stable@vger.kernel.org>	[4.14+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2019-10-19 06:32:32 -04:00
..
2019-10-18 08:38:26 -07:00
2019-09-22 09:39:09 -07:00
2019-09-30 10:04:28 -07:00
2019-10-03 09:15:19 -07:00
2019-09-22 09:30:30 -07:00
2019-09-22 09:39:09 -07:00
2019-09-19 14:14:28 -07:00
2019-09-18 11:14:31 -07:00
2019-09-22 12:02:21 -07:00
2019-09-28 20:44:12 +02:00
2019-09-22 09:30:30 -07:00
2019-10-09 09:46:46 -07:00
2019-09-23 17:20:40 -04:00
2019-09-29 10:33:41 -07:00
2019-10-15 23:51:36 +02:00
2019-09-23 19:16:01 -07:00
2019-09-27 12:19:47 -07:00
2019-09-17 18:40:42 -07:00
2019-09-22 10:55:08 -07:00
2019-09-30 10:04:28 -07:00
2019-09-22 11:05:43 -07:00
2019-10-15 12:19:08 -07:00
2019-09-16 15:52:38 -07:00
2019-09-22 10:52:23 -07:00
2019-09-17 18:40:42 -07:00
2019-09-24 15:54:08 -07:00
2019-09-18 11:14:31 -07:00
2019-09-27 11:17:38 -07:00
2019-10-12 14:11:21 -07:00
2019-09-18 11:05:34 -07:00