diff options
author | Daeseok Youn <daeseok.youn@gmail.com> | 2014-03-25 23:01:48 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-04-15 17:46:43 -0400 |
commit | 1a52489318c16aaff71059b3892a1a2f3bb8ecec (patch) | |
tree | 1c5162477fe64b84cb30963c017ce318702ae7b1 | |
parent | d06fb58cb63c66ddcc2ac94edf99f505f4919da0 (diff) |
staging: vme: fix memory leak in vme_user_probe()
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>
-rw-r--r-- | drivers/staging/vme/devices/vme_user.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 792792715673..ffb4eeefdddb 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c | |||
@@ -776,7 +776,8 @@ static int vme_user_probe(struct vme_dev *vdev) | |||
776 | image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL); | 776 | image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL); |
777 | if (image[i].kern_buf == NULL) { | 777 | if (image[i].kern_buf == NULL) { |
778 | err = -ENOMEM; | 778 | err = -ENOMEM; |
779 | goto err_master_buf; | 779 | vme_master_free(image[i].resource); |
780 | goto err_master; | ||
780 | } | 781 | } |
781 | } | 782 | } |
782 | 783 | ||
@@ -819,8 +820,6 @@ static int vme_user_probe(struct vme_dev *vdev) | |||
819 | 820 | ||
820 | return 0; | 821 | return 0; |
821 | 822 | ||
822 | /* Ensure counter set correcty to destroy all sysfs devices */ | ||
823 | i = VME_DEVS; | ||
824 | err_sysfs: | 823 | err_sysfs: |
825 | while (i > 0) { | 824 | while (i > 0) { |
826 | i--; | 825 | i--; |
@@ -830,12 +829,10 @@ err_sysfs: | |||
830 | 829 | ||
831 | /* Ensure counter set correcty to unalloc all master windows */ | 830 | /* Ensure counter set correcty to unalloc all master windows */ |
832 | i = MASTER_MAX + 1; | 831 | i = MASTER_MAX + 1; |
833 | err_master_buf: | ||
834 | for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++) | ||
835 | kfree(image[i].kern_buf); | ||
836 | err_master: | 832 | err_master: |
837 | while (i > MASTER_MINOR) { | 833 | while (i > MASTER_MINOR) { |
838 | i--; | 834 | i--; |
835 | kfree(image[i].kern_buf); | ||
839 | vme_master_free(image[i].resource); | 836 | vme_master_free(image[i].resource); |
840 | } | 837 | } |
841 | 838 | ||