diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2016-08-19 04:04:54 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@s-opensource.com> | 2016-08-24 16:20:45 -0400 |
commit | fb6609280db902bd5d34445fba1c926e95e63914 (patch) | |
tree | 13286596c1bbea4a203f63dd2a69a09794b8cd6a /drivers/media/dvb-core | |
parent | 8eb14e8084b0f39dbf23dcd0c263fc2fac862048 (diff) |
[media] dvb_frontend: Use memdup_user() rather than duplicating its implementation
* Reuse existing functionality from memdup_user() instead of keeping
duplicate source code.
This issue was detected by using the Coccinelle software.
* Return directly if this copy operation failed.
* Replace the specification of data structures by pointer dereferences
to make the corresponding size determination a bit safer according to
the Linux coding style convention.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers/media/dvb-core')
-rw-r--r-- | drivers/media/dvb-core/dvb_frontend.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/drivers/media/dvb-core/dvb_frontend.c b/drivers/media/dvb-core/dvb_frontend.c index be99c8dbc5f8..01511e5a5566 100644 --- a/drivers/media/dvb-core/dvb_frontend.c +++ b/drivers/media/dvb-core/dvb_frontend.c | |||
@@ -1969,17 +1969,9 @@ static int dvb_frontend_ioctl_properties(struct file *file, | |||
1969 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) | 1969 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) |
1970 | return -EINVAL; | 1970 | return -EINVAL; |
1971 | 1971 | ||
1972 | tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL); | 1972 | tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp)); |
1973 | if (!tvp) { | 1973 | if (IS_ERR(tvp)) |
1974 | err = -ENOMEM; | 1974 | return PTR_ERR(tvp); |
1975 | goto out; | ||
1976 | } | ||
1977 | |||
1978 | if (copy_from_user(tvp, (void __user *)tvps->props, | ||
1979 | tvps->num * sizeof(struct dtv_property))) { | ||
1980 | err = -EFAULT; | ||
1981 | goto out; | ||
1982 | } | ||
1983 | 1975 | ||
1984 | for (i = 0; i < tvps->num; i++) { | 1976 | for (i = 0; i < tvps->num; i++) { |
1985 | err = dtv_property_process_set(fe, tvp + i, file); | 1977 | err = dtv_property_process_set(fe, tvp + i, file); |
@@ -2002,17 +1994,9 @@ static int dvb_frontend_ioctl_properties(struct file *file, | |||
2002 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) | 1994 | if ((tvps->num == 0) || (tvps->num > DTV_IOCTL_MAX_MSGS)) |
2003 | return -EINVAL; | 1995 | return -EINVAL; |
2004 | 1996 | ||
2005 | tvp = kmalloc(tvps->num * sizeof(struct dtv_property), GFP_KERNEL); | 1997 | tvp = memdup_user(tvps->props, tvps->num * sizeof(*tvp)); |
2006 | if (!tvp) { | 1998 | if (IS_ERR(tvp)) |
2007 | err = -ENOMEM; | 1999 | return PTR_ERR(tvp); |
2008 | goto out; | ||
2009 | } | ||
2010 | |||
2011 | if (copy_from_user(tvp, (void __user *)tvps->props, | ||
2012 | tvps->num * sizeof(struct dtv_property))) { | ||
2013 | err = -EFAULT; | ||
2014 | goto out; | ||
2015 | } | ||
2016 | 2000 | ||
2017 | /* | 2001 | /* |
2018 | * Let's use our own copy of property cache, in order to | 2002 | * Let's use our own copy of property cache, in order to |