* [PATCH] media: cx23885: check allocation return
@ 2019-01-20 3:52 Nicholas Mc Guire
0 siblings, 0 replies; only message in thread
From: Nicholas Mc Guire @ 2019-01-20 3:52 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: Brad Love, Hans Verkuil, Kees Cook, linux-media, linux-kernel,
Nicholas Mc Guire
Checking of kmalloc() seems to have been committed - as
cx23885_dvb_register() is checking for != 0 return, returning
-ENOMEM should be fine here. While at it address the coccicheck
suggestion to move to kmemdup rather than using kmalloc+memcpy.
Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Fixes: 46b21bbaa8a8 ("[media] Add support for DViCO FusionHDTV DVB-T Dual Express2")
---
Problem located with an experimental coccinelle script
Patch was compile tested with: x86_64_defconfig + MEDIA_SUPPORT=y
MEDIA_PCI_SUPPORT=y, MEDIA_DIGITAL_TV_SUPPORT=y,
MEDIA_ANALOG_TV_SUPPORT=y (for VIDEO_DEV), RC_CORE=y
VIDEO_CX23885=y
The coccicheck on the initial fix for kmalloc only reported:
drivers/media/pci/cx23885//cx23885-dvb.c:1477:33-40: WARNING opportunity for kmemdup
so that was merged into this patch - the return value still needs to
be checked.
Patch is against 5.0-rc2 (localversion-next is next-20190118)
drivers/media/pci/cx23885/cx23885-dvb.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 0d0929c..225cdfe 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1474,8 +1474,11 @@ static int dvb_register(struct cx23885_tsport *port)
if (fe0->dvb.frontend != NULL) {
struct i2c_adapter *tun_i2c;
- fe0->dvb.frontend->sec_priv = kmalloc(sizeof(dib7000p_ops), GFP_KERNEL);
- memcpy(fe0->dvb.frontend->sec_priv, &dib7000p_ops, sizeof(dib7000p_ops));
+ fe0->dvb.frontend->sec_priv = kmemdup(&dib7000p_ops,
+ sizeof(dib7000p_ops),
+ GFP_KERNEL);
+ if (!fe0->dvb.frontend->sec_priv)
+ return -ENOMEM;
tun_i2c = dib7000p_ops.get_i2c_master(fe0->dvb.frontend, DIBX000_I2C_INTERFACE_TUNER, 1);
if (!dvb_attach(dib0070_attach, fe0->dvb.frontend, tun_i2c, &dib7070p_dib0070_config))
return -ENODEV;
--
2.1.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-01-20 3:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-20 3:52 [PATCH] media: cx23885: check allocation return Nicholas Mc Guire
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).