OSDN Git Service

writeback: fix memory leak in wb_queue_work()
authorTahsin Erdogan <tahsin@google.com>
Fri, 10 Mar 2017 20:09:49 +0000 (12:09 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Dec 2017 09:04:54 +0000 (10:04 +0100)
commitb424289863d09900643c8e2dd6fa53a465895258
tree877041dc3670c41096cc276e8da3b133a477688c
parentfbdf477fcff6b16869665cbf7a38c1b6dbfe0d8a
writeback: fix memory leak in wb_queue_work()

[ Upstream commit 4a3a485b1ed0e109718cc8c9d094fa0f552de9b2 ]

When WB_registered flag is not set, wb_queue_work() skips queuing the
work, but does not perform the necessary clean up. In particular, if
work->auto_free is true, it should free the memory.

The leak condition can be reprouced by following these steps:

   mount /dev/sdb /mnt/sdb
   /* In qemu console: device_del sdb */
   umount /dev/sdb

Above will result in a wb_queue_work() call on an unregistered wb and
thus leak memory.

Reported-by: John Sperbeck <jsperbeck@google.com>
Signed-off-by: Tahsin Erdogan <tahsin@google.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Sasha Levin <alexander.levin@verizon.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/fs-writeback.c