diff options
author | Seung-Woo Kim | 2017-03-19 19:52:49 -0500 |
---|---|---|
committer | Emil Velikov | 2017-04-03 11:46:06 -0500 |
commit | 2dc30dd5279fea1838f181724fb699a3689f582b (patch) | |
tree | 7b759a9b3d935db1e7a1a61e17a0b1d3188b85b4 /tests/exynos | |
parent | a398adba7c845fe248ab1e5c338789ca2882644b (diff) | |
download | external-libgbm-2dc30dd5279fea1838f181724fb699a3689f582b.tar.gz external-libgbm-2dc30dd5279fea1838f181724fb699a3689f582b.tar.xz external-libgbm-2dc30dd5279fea1838f181724fb699a3689f582b.zip |
tests/exynos: fix invalid code of error path in g2d test
This patch fixes invalid code of error path including NULL
deference and leak in g2d test.
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Diffstat (limited to 'tests/exynos')
-rw-r--r-- | tests/exynos/exynos_fimg2d_test.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c index 3495c626..ab1028e8 100644 --- a/tests/exynos/exynos_fimg2d_test.c +++ b/tests/exynos/exynos_fimg2d_test.c | |||
@@ -59,7 +59,6 @@ static void connector_find_mode(int fd, struct connector *c, | |||
59 | if (!connector) { | 59 | if (!connector) { |
60 | fprintf(stderr, "could not get connector %i: %s\n", | 60 | fprintf(stderr, "could not get connector %i: %s\n", |
61 | resources->connectors[i], strerror(errno)); | 61 | resources->connectors[i], strerror(errno)); |
62 | drmModeFreeConnector(connector); | ||
63 | continue; | 62 | continue; |
64 | } | 63 | } |
65 | 64 | ||
@@ -98,7 +97,6 @@ static void connector_find_mode(int fd, struct connector *c, | |||
98 | if (!c->encoder) { | 97 | if (!c->encoder) { |
99 | fprintf(stderr, "could not get encoder %i: %s\n", | 98 | fprintf(stderr, "could not get encoder %i: %s\n", |
100 | resources->encoders[i], strerror(errno)); | 99 | resources->encoders[i], strerror(errno)); |
101 | drmModeFreeEncoder(c->encoder); | ||
102 | continue; | 100 | continue; |
103 | } | 101 | } |
104 | 102 | ||
@@ -264,7 +262,8 @@ static int g2d_copy_test(struct exynos_device *dev, struct exynos_bo *src, | |||
264 | userptr = (unsigned long)malloc(size); | 262 | userptr = (unsigned long)malloc(size); |
265 | if (!userptr) { | 263 | if (!userptr) { |
266 | fprintf(stderr, "failed to allocate userptr.\n"); | 264 | fprintf(stderr, "failed to allocate userptr.\n"); |
267 | return -EFAULT; | 265 | ret = -EFAULT; |
266 | goto fail; | ||
268 | } | 267 | } |
269 | 268 | ||
270 | src_img.user_ptr[0].userptr = userptr; | 269 | src_img.user_ptr[0].userptr = userptr; |
@@ -469,7 +468,8 @@ static int g2d_copy_with_scale_test(struct exynos_device *dev, | |||
469 | userptr = (unsigned long)malloc(size); | 468 | userptr = (unsigned long)malloc(size); |
470 | if (!userptr) { | 469 | if (!userptr) { |
471 | fprintf(stderr, "failed to allocate userptr.\n"); | 470 | fprintf(stderr, "failed to allocate userptr.\n"); |
472 | return -EFAULT; | 471 | ret = -EFAULT; |
472 | goto fail; | ||
473 | } | 473 | } |
474 | 474 | ||
475 | src_img.user_ptr[0].userptr = userptr; | 475 | src_img.user_ptr[0].userptr = userptr; |
@@ -520,7 +520,7 @@ err_free_userptr: | |||
520 | fail: | 520 | fail: |
521 | g2d_fini(ctx); | 521 | g2d_fini(ctx); |
522 | 522 | ||
523 | return 0; | 523 | return ret;; |
524 | } | 524 | } |
525 | 525 | ||
526 | #if EXYNOS_G2D_USERPTR_TEST | 526 | #if EXYNOS_G2D_USERPTR_TEST |
@@ -558,7 +558,8 @@ static int g2d_blend_test(struct exynos_device *dev, | |||
558 | userptr = (unsigned long)malloc(size); | 558 | userptr = (unsigned long)malloc(size); |
559 | if (!userptr) { | 559 | if (!userptr) { |
560 | fprintf(stderr, "failed to allocate userptr.\n"); | 560 | fprintf(stderr, "failed to allocate userptr.\n"); |
561 | return -EFAULT; | 561 | ret = -EFAULT; |
562 | goto fail; | ||
562 | } | 563 | } |
563 | 564 | ||
564 | src_img.user_ptr[0].userptr = userptr; | 565 | src_img.user_ptr[0].userptr = userptr; |
@@ -620,7 +621,7 @@ err_free_userptr: | |||
620 | fail: | 621 | fail: |
621 | g2d_fini(ctx); | 622 | g2d_fini(ctx); |
622 | 623 | ||
623 | return 0; | 624 | return ret; |
624 | } | 625 | } |
625 | #endif | 626 | #endif |
626 | 627 | ||
@@ -647,8 +648,8 @@ static int g2d_checkerboard_test(struct exynos_device *dev, | |||
647 | dst_y = 0; | 648 | dst_y = 0; |
648 | 649 | ||
649 | checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32); | 650 | checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32); |
650 | if (checkerboard == NULL) { | 651 | if (!checkerboard) { |
651 | ret = -1; | 652 | ret = -EFAULT; |
652 | goto fail; | 653 | goto fail; |
653 | } | 654 | } |
654 | 655 | ||
@@ -757,8 +758,8 @@ int main(int argc, char **argv) | |||
757 | 758 | ||
758 | dev = exynos_device_create(fd); | 759 | dev = exynos_device_create(fd); |
759 | if (!dev) { | 760 | if (!dev) { |
760 | drmClose(dev->fd); | 761 | ret = -EFAULT; |
761 | return -EFAULT; | 762 | goto err_drm_close; |
762 | } | 763 | } |
763 | 764 | ||
764 | resources = drmModeGetResources(dev->fd); | 765 | resources = drmModeGetResources(dev->fd); |
@@ -766,7 +767,7 @@ int main(int argc, char **argv) | |||
766 | fprintf(stderr, "drmModeGetResources failed: %s\n", | 767 | fprintf(stderr, "drmModeGetResources failed: %s\n", |
767 | strerror(errno)); | 768 | strerror(errno)); |
768 | ret = -EFAULT; | 769 | ret = -EFAULT; |
769 | goto err_drm_close; | 770 | goto err_dev_destory; |
770 | } | 771 | } |
771 | 772 | ||
772 | connector_find_mode(dev->fd, &con, resources); | 773 | connector_find_mode(dev->fd, &con, resources); |
@@ -775,7 +776,7 @@ int main(int argc, char **argv) | |||
775 | if (!con.mode) { | 776 | if (!con.mode) { |
776 | fprintf(stderr, "failed to find usable connector\n"); | 777 | fprintf(stderr, "failed to find usable connector\n"); |
777 | ret = -EFAULT; | 778 | ret = -EFAULT; |
778 | goto err_drm_close; | 779 | goto err_dev_destory; |
779 | } | 780 | } |
780 | 781 | ||
781 | screen_width = con.mode->hdisplay; | 782 | screen_width = con.mode->hdisplay; |
@@ -784,7 +785,7 @@ int main(int argc, char **argv) | |||
784 | if (screen_width == 0 || screen_height == 0) { | 785 | if (screen_width == 0 || screen_height == 0) { |
785 | fprintf(stderr, "failed to find sane resolution on connector\n"); | 786 | fprintf(stderr, "failed to find sane resolution on connector\n"); |
786 | ret = -EFAULT; | 787 | ret = -EFAULT; |
787 | goto err_drm_close; | 788 | goto err_dev_destory; |
788 | } | 789 | } |
789 | 790 | ||
790 | printf("screen width = %d, screen height = %d\n", screen_width, | 791 | printf("screen width = %d, screen height = %d\n", screen_width, |
@@ -793,7 +794,7 @@ int main(int argc, char **argv) | |||
793 | bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0); | 794 | bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0); |
794 | if (!bo) { | 795 | if (!bo) { |
795 | ret = -EFAULT; | 796 | ret = -EFAULT; |
796 | goto err_drm_close; | 797 | goto err_dev_destory; |
797 | } | 798 | } |
798 | 799 | ||
799 | handles[0] = bo->handle; | 800 | handles[0] = bo->handle; |
@@ -884,9 +885,11 @@ err_rm_fb: | |||
884 | err_destroy_buffer: | 885 | err_destroy_buffer: |
885 | exynos_destroy_buffer(bo); | 886 | exynos_destroy_buffer(bo); |
886 | 887 | ||
887 | err_drm_close: | 888 | err_dev_destory: |
888 | drmClose(dev->fd); | ||
889 | exynos_device_destroy(dev); | 889 | exynos_device_destroy(dev); |
890 | 890 | ||
891 | return 0; | 891 | err_drm_close: |
892 | drmClose(fd); | ||
893 | |||
894 | return ret; | ||
892 | } | 895 | } |