diff options
author | Fuqian Huang <huangfq.daxian@gmail.com> | 2019-07-03 19:28:48 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+samsung@kernel.org> | 2019-08-14 11:03:11 +0300 |
commit | 48059784ebac75a98e024c29ab301e05a8b8012f (patch) | |
tree | 23cc37e91ad214bd5db1c87d14283f7ca72865b5 /drivers/media/tuners/xc4000.c | |
parent | 771560e5d341dc61f9e87bc715f3dbb4efe6ec62 (diff) | |
download | linux-48059784ebac75a98e024c29ab301e05a8b8012f.tar.xz |
media: media/tuners: Use kmemdup rather than duplicating its implementation
kmemdup is introduced to duplicate a region of memory in a neat way.
Rather than kmalloc/kzalloc + memcpy, which the programmer needs to
write the size twice (sometimes lead to mistakes), kmemdup improves
readability, leads to smaller code and also reduce the chances of mistakes.
Suggestion to use kmemdup rather than using kmalloc/kzalloc + memcpy.
Signed-off-by: Fuqian Huang <huangfq.daxian@gmail.com>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Diffstat (limited to 'drivers/media/tuners/xc4000.c')
-rw-r--r-- | drivers/media/tuners/xc4000.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/media/tuners/xc4000.c b/drivers/media/tuners/xc4000.c index 43925e219d81..d9606738ce43 100644 --- a/drivers/media/tuners/xc4000.c +++ b/drivers/media/tuners/xc4000.c @@ -812,7 +812,7 @@ static int xc4000_fwupload(struct dvb_frontend *fe) goto corrupt; } - priv->firm[n].ptr = kzalloc(size, GFP_KERNEL); + priv->firm[n].ptr = kmemdup(p, size, GFP_KERNEL); if (priv->firm[n].ptr == NULL) { printk(KERN_ERR "Not enough memory to load firmware file.\n"); rc = -ENOMEM; @@ -826,7 +826,6 @@ static int xc4000_fwupload(struct dvb_frontend *fe) type, (unsigned long long)id, size); } - memcpy(priv->firm[n].ptr, p, size); priv->firm[n].type = type; priv->firm[n].id = id; priv->firm[n].size = size; |