Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: dvb_frontend: fix return values for FE_SET_PROPERTY

There are several problems with regards to the return of
FE_SET_PROPERTY. The original idea were to return per-property
return codes via tvp->result field, and to return an updated
set of values.

However, that never worked. What's actually implemented is:

- the FE_SET_PROPERTY implementation doesn't call .get_frontend
callback in order to get the actual parameters after return;

- the tvp->result field is only filled if there's no error.
So, it is always filled with zero;

- FE_SET_PROPERTY doesn't call memdup_user() nor any other
copy_to_user() function. So, any changes to the properties
will be lost;

- FE_SET_PROPERTY is declared as a write-only ioctl (IOW).

While we could fix the above, it could cause regressions.

So, let's just assume what the code really does, updating
the documentation accordingly and removing the logic that
would update the discarded tvp->result.

Reviewed-by: Shuah Khan <shuahkh@osg.samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>

+6 -5
+5 -2
Documentation/media/uapi/dvb/fe-get-property.rst
··· 48 48 49 49 - This call requires read/write access to the device. 50 50 51 - - At return, the values are updated to reflect the actual parameters 52 - used. 51 + .. note:: 52 + 53 + At return, the values aren't updated to reflect the actual 54 + parameters used. If the actual parameters are needed, an explicit 55 + call to ``FE_GET_PROPERTY`` is needed. 53 56 54 57 - ``FE_GET_PROPERTY:`` 55 58
-2
drivers/media/dvb-core/dvb_frontend.c
··· 2125 2125 kfree(tvp); 2126 2126 return err; 2127 2127 } 2128 - (tvp + i)->result = err; 2129 2128 } 2130 2129 kfree(tvp); 2131 2130 break; ··· 2169 2170 kfree(tvp); 2170 2171 return err; 2171 2172 } 2172 - (tvp + i)->result = err; 2173 2173 } 2174 2174 2175 2175 if (copy_to_user((void __user *)tvps->props, tvp,
+1 -1
include/uapi/linux/dvb/frontend.h
··· 830 830 * @cmd: Digital TV command. 831 831 * @reserved: Not used. 832 832 * @u: Union with the values for the command. 833 - * @result: Result of the command set (currently unused). 833 + * @result: Unused 834 834 * 835 835 * The @u union may have either one of the values below: 836 836 *