Skip to content

Commit

Permalink
staging: vme: fix memory leak in vme_user_probe()
Browse files Browse the repository at this point in the history
If vme_master_request() returns NULL when it failed,
it need to free buffers for master.

And also removes unreachable code in vme_user_probe().

Signed-off-by: Daeseok Youn <daeseok.youn@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Daeseok Youn authored and Greg Kroah-Hartman committed Apr 15, 2014
1 parent d06fb58 commit 1a52489
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions drivers/staging/vme/devices/vme_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,8 @@ static int vme_user_probe(struct vme_dev *vdev)
image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL);
if (image[i].kern_buf == NULL) {
err = -ENOMEM;
goto err_master_buf;
vme_master_free(image[i].resource);
goto err_master;
}
}

Expand Down Expand Up @@ -819,8 +820,6 @@ static int vme_user_probe(struct vme_dev *vdev)

return 0;

/* Ensure counter set correcty to destroy all sysfs devices */
i = VME_DEVS;
err_sysfs:
while (i > 0) {
i--;
Expand All @@ -830,12 +829,10 @@ static int vme_user_probe(struct vme_dev *vdev)

/* Ensure counter set correcty to unalloc all master windows */
i = MASTER_MAX + 1;
err_master_buf:
for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++)
kfree(image[i].kern_buf);
err_master:
while (i > MASTER_MINOR) {
i--;
kfree(image[i].kern_buf);
vme_master_free(image[i].resource);
}

Expand Down

0 comments on commit 1a52489

Please sign in to comment.