[RHEL8,COMMIT] ploop: Do not allocate excess memory on add_delta

Submitted by Konstantin Khorenko on Dec. 10, 2019, 3:07 p.m.

Details

Message ID 201912101507.xBAF7Zng023619@finist_co8.work.ct
State New
Series "ploop: Do not allocate excess memory on add_delta"
Headers show

Commit Message

Konstantin Khorenko Dec. 10, 2019, 3:07 p.m.
The commit is pushed to "branch-rh8-4.18.0-80.1.2.vz8.2.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh8-4.18.0-80.1.2.vz8.2.6
------>
commit 029e93b1548af6547afbd04fa5382ed9b4ba5c73
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Tue Dec 10 18:07:35 2019 +0300

    ploop: Do not allocate excess memory on add_delta
    
    Here must be sizeof(struct file *) instead of sizeof(struct file).
    
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/md/dm-ploop-cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/md/dm-ploop-cmd.c b/drivers/md/dm-ploop-cmd.c
index 8c94fcf4bb67..86e6804037ba 100644
--- a/drivers/md/dm-ploop-cmd.c
+++ b/drivers/md/dm-ploop-cmd.c
@@ -591,10 +591,10 @@  int ploop_add_delta(struct ploop *ploop, const char *arg)
 		goto out;
 
 	ret = -ENOMEM;
-	deltas = kcalloc(level + 1, sizeof(*file), GFP_KERNEL);
+	deltas = kcalloc(level + 1, sizeof(*deltas), GFP_KERNEL);
 	if (!deltas)
 		goto out;
-	size = level * sizeof(*file);
+	size = level * sizeof(*deltas);
 	memcpy(deltas, ploop->deltas, size);
 	deltas[level] = file;
 	/*