* [RFC/PATCH] v4l2-compliance: Reject invalid ioctl error codes
@ 2012-12-23 22:24 Laurent Pinchart
2012-12-24 9:24 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Laurent Pinchart @ 2012-12-23 22:24 UTC (permalink / raw)
To: linux-media; +Cc: hans.verkuil
The recent uvcvideo regression that broke pulseaudio/KDE (see commit
9c016d61097cc39427a2f5025bdd97ac633d26a6 in the mainline kernel) was
caused by the uvcvideo driver returning a -ENOENT error code to
userspace by mistake.
To make sure such regressions will be caught before reaching users, test
ioctl error codes to make sure they're valid.
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
utils/v4l2-compliance/v4l2-compliance.cpp | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
A white list of valid error codes might be more appropriate. I can fix the
patch accordingly, but I'd like a general opinion first.
diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
index 1e4646f..ff1ad9b 100644
--- a/utils/v4l2-compliance/v4l2-compliance.cpp
+++ b/utils/v4l2-compliance/v4l2-compliance.cpp
@@ -112,6 +112,13 @@ int doioctl_name(struct node *node, unsigned long int request, void *parm, const
fail("%s returned %d instead of 0 or -1\n", name, retval);
return -1;
}
+
+ /* Reject invalid error codes */
+ switch (errno) {
+ case ENOENT:
+ fail("%s returned invalid error %d\n", name, errno);
+ break;
+ }
return e;
}
--
Regards,
Laurent Pinchart
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [RFC/PATCH] v4l2-compliance: Reject invalid ioctl error codes
2012-12-23 22:24 [RFC/PATCH] v4l2-compliance: Reject invalid ioctl error codes Laurent Pinchart
@ 2012-12-24 9:24 ` Hans Verkuil
2012-12-24 12:30 ` Laurent Pinchart
0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2012-12-24 9:24 UTC (permalink / raw)
To: Laurent Pinchart; +Cc: linux-media, hans.verkuil
On Sun December 23 2012 23:24:04 Laurent Pinchart wrote:
> The recent uvcvideo regression that broke pulseaudio/KDE (see commit
> 9c016d61097cc39427a2f5025bdd97ac633d26a6 in the mainline kernel) was
> caused by the uvcvideo driver returning a -ENOENT error code to
> userspace by mistake.
>
> To make sure such regressions will be caught before reaching users, test
> ioctl error codes to make sure they're valid.
I don't like this change. Error codes should be checked in the test for
the actual ioctl.
Apparently it is QUERYCTRL that is returning the wrong error code in uvc, but
looking at the code in v4l2-test-controls.cpp it is already checking for ENOTTY
or EINVAL and returning a failure if it is a different error code. So why is
that not triggered in this case?
Regards,
Hans
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> ---
> utils/v4l2-compliance/v4l2-compliance.cpp | 7 +++++++
> 1 files changed, 7 insertions(+), 0 deletions(-)
>
> A white list of valid error codes might be more appropriate. I can fix the
> patch accordingly, but I'd like a general opinion first.
>
> diff --git a/utils/v4l2-compliance/v4l2-compliance.cpp b/utils/v4l2-compliance/v4l2-compliance.cpp
> index 1e4646f..ff1ad9b 100644
> --- a/utils/v4l2-compliance/v4l2-compliance.cpp
> +++ b/utils/v4l2-compliance/v4l2-compliance.cpp
> @@ -112,6 +112,13 @@ int doioctl_name(struct node *node, unsigned long int request, void *parm, const
> fail("%s returned %d instead of 0 or -1\n", name, retval);
> return -1;
> }
> +
> + /* Reject invalid error codes */
> + switch (errno) {
> + case ENOENT:
> + fail("%s returned invalid error %d\n", name, errno);
> + break;
> + }
> return e;
> }
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [RFC/PATCH] v4l2-compliance: Reject invalid ioctl error codes
2012-12-24 9:24 ` Hans Verkuil
@ 2012-12-24 12:30 ` Laurent Pinchart
0 siblings, 0 replies; 3+ messages in thread
From: Laurent Pinchart @ 2012-12-24 12:30 UTC (permalink / raw)
To: Hans Verkuil; +Cc: linux-media, hans.verkuil
Hi Hans,
On Monday 24 December 2012 10:24:48 Hans Verkuil wrote:
> On Sun December 23 2012 23:24:04 Laurent Pinchart wrote:
> > The recent uvcvideo regression that broke pulseaudio/KDE (see commit
> > 9c016d61097cc39427a2f5025bdd97ac633d26a6 in the mainline kernel) was
> > caused by the uvcvideo driver returning a -ENOENT error code to
> > userspace by mistake.
> >
> > To make sure such regressions will be caught before reaching users, test
> > ioctl error codes to make sure they're valid.
>
> I don't like this change. Error codes should be checked in the test for
> the actual ioctl.
>
> Apparently it is QUERYCTRL that is returning the wrong error code in uvc,
> but looking at the code in v4l2-test-controls.cpp it is already checking
> for ENOTTY or EINVAL and returning a failure if it is a different error
> code. So why is that not triggered in this case?
I've just checked that, the missing control class issue made the control tests
stop early before hitting the wrong return value. I guess that's a good reason
to fix *all* compliance errors...
We can drop this patch.
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-12-24 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-23 22:24 [RFC/PATCH] v4l2-compliance: Reject invalid ioctl error codes Laurent Pinchart
2012-12-24 9:24 ` Hans Verkuil
2012-12-24 12:30 ` Laurent Pinchart
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).