[PATCH libdrm 3/5] modetest: fix to proper error path handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This patch needs to destroy and to remove buffer and framebuffer
properly from error path of set_mode and test_page_flip.

Signed-off-by: Joonyoung Shim <jy0922.shim@xxxxxxxxxxx>
---
 tests/modetest/modetest.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 6377459..eec4fd8 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -1074,6 +1074,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 	if (bo == NULL)
 		return;
 
+	dev->mode.bo = bo;
+
 	ret = drmModeAddFB2(dev->fd, dev->mode.width, dev->mode.height,
 			    pipes[0].fourcc, handles, pitches, offsets, &fb_id, 0);
 	if (ret) {
@@ -1082,6 +1084,8 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 		return;
 	}
 
+	dev->mode.fb_id = fb_id;
+
 	x = 0;
 	for (i = 0; i < count; i++) {
 		struct pipe_arg *pipe = &pipes[i];
@@ -1109,9 +1113,6 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
 			return;
 		}
 	}
-
-	dev->mode.bo = bo;
-	dev->mode.fb_id = fb_id;
 }
 
 static void clear_mode(struct device *dev)
@@ -1192,7 +1193,7 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
 			    &other_fb_id, 0);
 	if (ret) {
 		fprintf(stderr, "failed to add fb: %s\n", strerror(errno));
-		return;
+		goto err;
 	}
 
 	for (i = 0; i < count; i++) {
@@ -1206,7 +1207,7 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
 				      pipe);
 		if (ret) {
 			fprintf(stderr, "failed to page flip: %s\n", strerror(errno));
-			return;
+			goto err_rmfb;
 		}
 		gettimeofday(&pipe->start, NULL);
 		pipe->swap_count = 0;
@@ -1258,7 +1259,9 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
 		drmHandleEvent(dev->fd, &evctx);
 	}
 
+err_rmfb:
 	drmModeRmFB(dev->fd, other_fb_id);
+err:
 	bo_destroy(other_bo);
 }
 
-- 
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux