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>main
parent
a398adba7c
commit
2dc30dd527
|
@ -59,7 +59,6 @@ static void connector_find_mode(int fd, struct connector *c,
|
||||||
if (!connector) {
|
if (!connector) {
|
||||||
fprintf(stderr, "could not get connector %i: %s\n",
|
fprintf(stderr, "could not get connector %i: %s\n",
|
||||||
resources->connectors[i], strerror(errno));
|
resources->connectors[i], strerror(errno));
|
||||||
drmModeFreeConnector(connector);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +97,6 @@ static void connector_find_mode(int fd, struct connector *c,
|
||||||
if (!c->encoder) {
|
if (!c->encoder) {
|
||||||
fprintf(stderr, "could not get encoder %i: %s\n",
|
fprintf(stderr, "could not get encoder %i: %s\n",
|
||||||
resources->encoders[i], strerror(errno));
|
resources->encoders[i], strerror(errno));
|
||||||
drmModeFreeEncoder(c->encoder);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,7 +262,8 @@ static int g2d_copy_test(struct exynos_device *dev, struct exynos_bo *src,
|
||||||
userptr = (unsigned long)malloc(size);
|
userptr = (unsigned long)malloc(size);
|
||||||
if (!userptr) {
|
if (!userptr) {
|
||||||
fprintf(stderr, "failed to allocate userptr.\n");
|
fprintf(stderr, "failed to allocate userptr.\n");
|
||||||
return -EFAULT;
|
ret = -EFAULT;
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_img.user_ptr[0].userptr = userptr;
|
src_img.user_ptr[0].userptr = userptr;
|
||||||
|
@ -469,7 +468,8 @@ static int g2d_copy_with_scale_test(struct exynos_device *dev,
|
||||||
userptr = (unsigned long)malloc(size);
|
userptr = (unsigned long)malloc(size);
|
||||||
if (!userptr) {
|
if (!userptr) {
|
||||||
fprintf(stderr, "failed to allocate userptr.\n");
|
fprintf(stderr, "failed to allocate userptr.\n");
|
||||||
return -EFAULT;
|
ret = -EFAULT;
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_img.user_ptr[0].userptr = userptr;
|
src_img.user_ptr[0].userptr = userptr;
|
||||||
|
@ -520,7 +520,7 @@ err_free_userptr:
|
||||||
fail:
|
fail:
|
||||||
g2d_fini(ctx);
|
g2d_fini(ctx);
|
||||||
|
|
||||||
return 0;
|
return ret;;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EXYNOS_G2D_USERPTR_TEST
|
#if EXYNOS_G2D_USERPTR_TEST
|
||||||
|
@ -558,7 +558,8 @@ static int g2d_blend_test(struct exynos_device *dev,
|
||||||
userptr = (unsigned long)malloc(size);
|
userptr = (unsigned long)malloc(size);
|
||||||
if (!userptr) {
|
if (!userptr) {
|
||||||
fprintf(stderr, "failed to allocate userptr.\n");
|
fprintf(stderr, "failed to allocate userptr.\n");
|
||||||
return -EFAULT;
|
ret = -EFAULT;
|
||||||
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
src_img.user_ptr[0].userptr = userptr;
|
src_img.user_ptr[0].userptr = userptr;
|
||||||
|
@ -620,7 +621,7 @@ err_free_userptr:
|
||||||
fail:
|
fail:
|
||||||
g2d_fini(ctx);
|
g2d_fini(ctx);
|
||||||
|
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -647,8 +648,8 @@ static int g2d_checkerboard_test(struct exynos_device *dev,
|
||||||
dst_y = 0;
|
dst_y = 0;
|
||||||
|
|
||||||
checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32);
|
checkerboard = create_checkerboard_pattern(screen_width / 32, screen_height / 32, 32);
|
||||||
if (checkerboard == NULL) {
|
if (!checkerboard) {
|
||||||
ret = -1;
|
ret = -EFAULT;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,8 +758,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
dev = exynos_device_create(fd);
|
dev = exynos_device_create(fd);
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
drmClose(dev->fd);
|
ret = -EFAULT;
|
||||||
return -EFAULT;
|
goto err_drm_close;
|
||||||
}
|
}
|
||||||
|
|
||||||
resources = drmModeGetResources(dev->fd);
|
resources = drmModeGetResources(dev->fd);
|
||||||
|
@ -766,7 +767,7 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr, "drmModeGetResources failed: %s\n",
|
fprintf(stderr, "drmModeGetResources failed: %s\n",
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto err_drm_close;
|
goto err_dev_destory;
|
||||||
}
|
}
|
||||||
|
|
||||||
connector_find_mode(dev->fd, &con, resources);
|
connector_find_mode(dev->fd, &con, resources);
|
||||||
|
@ -775,7 +776,7 @@ int main(int argc, char **argv)
|
||||||
if (!con.mode) {
|
if (!con.mode) {
|
||||||
fprintf(stderr, "failed to find usable connector\n");
|
fprintf(stderr, "failed to find usable connector\n");
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto err_drm_close;
|
goto err_dev_destory;
|
||||||
}
|
}
|
||||||
|
|
||||||
screen_width = con.mode->hdisplay;
|
screen_width = con.mode->hdisplay;
|
||||||
|
@ -784,7 +785,7 @@ int main(int argc, char **argv)
|
||||||
if (screen_width == 0 || screen_height == 0) {
|
if (screen_width == 0 || screen_height == 0) {
|
||||||
fprintf(stderr, "failed to find sane resolution on connector\n");
|
fprintf(stderr, "failed to find sane resolution on connector\n");
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto err_drm_close;
|
goto err_dev_destory;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("screen width = %d, screen height = %d\n", screen_width,
|
printf("screen width = %d, screen height = %d\n", screen_width,
|
||||||
|
@ -793,7 +794,7 @@ int main(int argc, char **argv)
|
||||||
bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);
|
bo = exynos_create_buffer(dev, screen_width * screen_height * 4, 0);
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
goto err_drm_close;
|
goto err_dev_destory;
|
||||||
}
|
}
|
||||||
|
|
||||||
handles[0] = bo->handle;
|
handles[0] = bo->handle;
|
||||||
|
@ -884,9 +885,11 @@ err_rm_fb:
|
||||||
err_destroy_buffer:
|
err_destroy_buffer:
|
||||||
exynos_destroy_buffer(bo);
|
exynos_destroy_buffer(bo);
|
||||||
|
|
||||||
err_drm_close:
|
err_dev_destory:
|
||||||
drmClose(dev->fd);
|
|
||||||
exynos_device_destroy(dev);
|
exynos_device_destroy(dev);
|
||||||
|
|
||||||
return 0;
|
err_drm_close:
|
||||||
|
drmClose(fd);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue