mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
Staging: zram: Fix memory leak by refcount mismatch
(cherry pick from commit 1b672224d1
)
As suggested by Minchan Kim and Jerome Marchand "The code in reset_store
get the block device (bdget_disk()) but it does not put it (bdput()) when
it's done using it. The usage count is therefore incremented but never
decremented."
This patch also puts bdput() for all error cases.
Acked-by: Minchan Kim <minchan@kernel.org>
Acked-by: Jerome Marchand <jmarchan@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 24810447
Change-Id: I034c6cc59426fee5ee6f069ae9cf9ca5395202a2
This commit is contained in:
parent
a4457001c7
commit
dfbe85d845
1 changed files with 18 additions and 7 deletions
|
@ -617,23 +617,34 @@ static ssize_t reset_store(struct device *dev,
|
|||
zram = dev_to_zram(dev);
|
||||
bdev = bdget_disk(zram->disk, 0);
|
||||
|
||||
if (!bdev)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Do not reset an active device! */
|
||||
if (bdev->bd_holders)
|
||||
return -EBUSY;
|
||||
if (bdev->bd_holders) {
|
||||
ret = -EBUSY;
|
||||
goto out;
|
||||
}
|
||||
|
||||
ret = kstrtou16(buf, 10, &do_reset);
|
||||
if (ret)
|
||||
return ret;
|
||||
goto out;
|
||||
|
||||
if (!do_reset)
|
||||
return -EINVAL;
|
||||
if (!do_reset) {
|
||||
ret = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Make sure all pending I/O is finished */
|
||||
if (bdev)
|
||||
fsync_bdev(bdev);
|
||||
fsync_bdev(bdev);
|
||||
bdput(bdev);
|
||||
|
||||
zram_reset_device(zram, true);
|
||||
return len;
|
||||
|
||||
out:
|
||||
bdput(bdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __zram_make_request(struct zram *zram, struct bio *bio, int rw)
|
||||
|
|
Loading…
Reference in a new issue