From 45033a900fb0d004b9790f7b9d57045ea7510cd3 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 10 Mar 2014 19:49:22 +0100 Subject: Read errno before media_dbg calls The media_dbg() in error paths can modify the errno value, leading to the wrong error (or no error at all) being returned. Fix this by reading the errno value before calling media_dbg(). Signed-off-by: Laurent Pinchart --- src/v4l2subdev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/v4l2subdev.c') diff --git a/src/v4l2subdev.c b/src/v4l2subdev.c index 2d45d7f..efc6708 100644 --- a/src/v4l2subdev.c +++ b/src/v4l2subdev.c @@ -45,10 +45,11 @@ int v4l2_subdev_open(struct media_entity *entity) entity->fd = open(entity->devname, O_RDWR); if (entity->fd == -1) { + int ret = -errno; media_dbg(entity->media, "%s: Failed to open subdev device node %s\n", __func__, entity->devname); - return -errno; + return ret; } return 0; -- cgit v1.2.3