dvb-core: dvb_frontend_handle_ioctl(): init err to -EOPNOTSUPP
PATCH 1/1 dvb-core: dvb_frontend_handle_ioctl(): init err to -EOPNOTSUPP
From: Daniel Scheller <[email protected]>
The mentioned commit cleaned up the ioctl handling, but caused an issue with the DVBv3 when they're not defined in a frontend's fe_ops: When a userspace application checks for existence and success of a fe_ops with ie.
if (!ioctl(fd, FE_READ_BER, &val))
this will not report failure anymore since in dvb_frontend_handle_ioctl(), err is unitialised and thus zero, and "case FE_READ_BER" (and the following) doesn't care about the case that fe_op isn't set by the frontend driver. So, success is always reported while the value at the passed ptr isn't updated. This breaks userspace applications relying on v3 stats.
Fix this by initialising err to -EOPNOTSUPP like it was before the commit. This only affects (and fixes) the DVBv3 stat ioctls, every other handled ioctl sets err to a proper return value.
---
Discovered and tested with TVHeadend (current GIT master HEAD) which does fallback to DVBv3 stats inquiry when v5 is absent.
drivers/media/dvb-core/dvb_frontend.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/media/dvb-core/dvb_frontend.c +2 -0
@@ -2113,6 +2113,8 @@ static int dvb_frontend_handle_ioctl(struct file *file,dev_dbg (fe->dvb->device,"%s:\n" , __func__); + err = -EOPNOTSUPP ; +switch (cmd) {case FE_SET_PROPERTY : {struct dtv_properties *tvps = parg;
Signature · 1 line
2.13.6
Em Mon, 30 Oct 2017 23:18:08 +0100
Daniel Scheller <[email protected]> escreveu:
Quoted 33 lines
From: Daniel Scheller <[email protected]>
Fixes d73dcf0cdb95 ("media: dvb_frontend: cleanup ioctl handling logic")The mentioned commit cleaned up the ioctl handling, but caused an issue with the DVBv3 when they're not defined in a frontend's
fe_ops: When a userspace application checks for existence and success of afe_opswith ie.if (!ioctl(fd,
FE_READ_BER, &val))this will not report failure anymore since in
dvb_frontend_handle_ioctl(), err is unitialised and thus zero, and "caseFE_READ_BER" (and the following) doesn't care about the case thatfe_opisn't set by the frontend driver. So, success is always reported while the value at the passed ptr isn't updated. This breaks userspace applications relying on v3 stats.Fix this by initialising err to
-EOPNOTSUPPlike it was before the commit. This only affects (and fixes) the DVBv3 stat ioctls, every other handled ioctl sets err to a proper return value.Signed-off-by Daniel Scheller <[email protected]>---
Discovered and tested with TVHeadend (current GIT master HEAD) which does fallback to DVBv3 stats inquiry when v5 is absent.drivers/media/dvb-core/dvb_frontend.c | 2 ++ 1 file changed, 2 insertions(+)drivers/media/dvb-core/dvb_frontend.c +0
-0
drivers/media/dvb-core/dvb_frontend.c static int dvb_frontend_handle_ioctl(struct file *file, · line 2117
Quoted 5 lines
drivers/media/dvb-core/dvb_frontend.c +2
-0@@ -2113,6 +2113,8 @@ static int dvb_frontend_handle_ioctl(struct file *file,dev_dbg (fe->dvb->device,"%s:\n" , __func__); + err = -EOPNOTSUPP ; +
This patch is incomplete and will cause troubles with DVBv5. The right fix is:
https://patchwork.linuxtv.org/patch/45277/
Could you please test reply to its tread with a tested-by if it passes on your tests?
Thanks,
Mauro