summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSeung-Woo Kim <sw0312.kim@samsung.com>2017-03-20 09:52:49 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2017-04-04 10:18:52 +0900
commit8c7b986ccfc9f4a3884d53f562378e1452e5c14d (patch)
tree68c5e0d66fa73c678dbfd0738c9b9d35d91844c2
parent8716211cb72d98cd71ca8bed63de52da00f4dba3 (diff)
downloadlibdrm-8c7b986ccfc9f4a3884d53f562378e1452e5c14d.tar.gz
libdrm-8c7b986ccfc9f4a3884d53f562378e1452e5c14d.tar.bz2
libdrm-8c7b986ccfc9f4a3884d53f562378e1452e5c14d.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> Updated to mainline merged version for the commit 9b8ed9dc4736 ("tests/exynos: fix memory issues in g2d test"). This and previous commit should be skipped for rebase. Change-Id: I6a3edb87bce3e3a1db86b6abc9b74ee17083ab1c Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
-rw-r--r--tests/exynos/exynos_fimg2d_test.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/tests/exynos/exynos_fimg2d_test.c b/tests/exynos/exynos_fimg2d_test.c
index bb32fac7..ab1028e8 100644
--- a/tests/exynos/exynos_fimg2d_test.c
+++ b/tests/exynos/exynos_fimg2d_test.c
@@ -520,7 +520,7 @@ err_free_userptr:
fail:
g2d_fini(ctx);
- return 0;
+ return ret;;
}
#if EXYNOS_G2D_USERPTR_TEST
@@ -621,7 +621,7 @@ err_free_userptr:
fail:
g2d_fini(ctx);
- return 0;
+ return ret;
}
#endif
@@ -648,8 +648,8 @@ static int g2d_checkerboard_test(struct exynos_device *dev,
dst_y = 0;
checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32);
- if (checkerboard == NULL) {
- ret = -1;
+ if (!checkerboard) {
+ ret = -EFAULT;
goto fail;
}
@@ -758,8 +758,8 @@ int main(int argc, char **argv)
dev = exynos_device_create(fd);
if (!dev) {
- drmClose(fd);
- return -EFAULT;
+ ret = -EFAULT;
+ goto err_drm_close;
}
resources = drmModeGetResources(dev->fd);
@@ -767,7 +767,7 @@ int main(int argc, char **argv)
fprintf(stderr, "drmModeGetResources failed: %s\n",
strerror(errno));
ret = -EFAULT;
- goto err_drm_close;
+ goto err_dev_destory;
}
connector_find_mode(dev->fd, &con, resources);
@@ -776,7 +776,7 @@ int main(int argc, char **argv)
if (!con.mode) {
fprintf(stderr, "failed to find usable connector\n");
ret = -EFAULT;
- goto err_drm_close;
+ goto err_dev_destory;
}
screen_width = con.mode->hdisplay;
@@ -785,7 +785,7 @@ int main(int argc, char **argv)
if (screen_width == 0 || screen_height == 0) {
fprintf(stderr, "failed to find sane resolution on connector\n");
ret = -EFAULT;
- goto err_drm_close;
+ goto err_dev_destory;
}
printf("screen width = %d, screen height = %d\n", screen_width,
@@ -794,7 +794,7 @@ int main(int argc, char **argv)
bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);
if (!bo) {
ret = -EFAULT;
- goto err_drm_close;
+ goto err_dev_destory;
}
handles[0] = bo->handle;
@@ -885,9 +885,11 @@ err_rm_fb:
err_destroy_buffer:
exynos_destroy_buffer(bo);
-err_drm_close:
- drmClose(dev->fd);
+err_dev_destory:
exynos_device_destroy(dev);
- return 0;
+err_drm_close:
+ drmClose(fd);
+
+ return ret;
}