linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Nicholas Mc Guire <hofrat@osadl.org>, Sean Young <sean@mess.org>,
	Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-media@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 062/174] media: cx23885: check allocation return
Date: Thu, 16 Jan 2020 12:40:59 -0500	[thread overview]
Message-ID: <20200116174251.24326-62-sashal@kernel.org> (raw)
In-Reply-To: <20200116174251.24326-1-sashal@kernel.org>

From: Nicholas Mc Guire <hofrat@osadl.org>

[ Upstream commit a3d7f22ef34ec4206b50ee121384d5c8bebd5591 ]

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.

Fixes: 46b21bbaa8a8 ("[media] Add support for DViCO FusionHDTV DVB-T Dual Express2")

Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org>
Signed-off-by: Sean Young <sean@mess.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/media/pci/cx23885/cx23885-dvb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index e543cbbf2ec4..8fe78b8b1c25 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -1452,8 +1452,9 @@ 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.20.1


  parent reply	other threads:[~2020-01-16 17:55 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200116174251.24326-1-sashal@kernel.org>
2020-01-16 17:40 ` [PATCH AUTOSEL 4.4 032/174] media: s5p-jpeg: Correct step and max values for V4L2_CID_JPEG_RESTART_INTERVAL Sasha Levin
2020-01-16 17:40 ` [PATCH AUTOSEL 4.4 059/174] media: ivtv: update *pos correctly in ivtv_read_pos() Sasha Levin
2020-01-16 17:40 ` [PATCH AUTOSEL 4.4 060/174] media: cx18: update *pos correctly in cx18_read_pos() Sasha Levin
2020-01-16 17:40 ` [PATCH AUTOSEL 4.4 061/174] media: wl128x: Fix an error code in fm_download_firmware() Sasha Levin
2020-01-16 17:40 ` Sasha Levin [this message]
2020-01-16 17:41 ` [PATCH AUTOSEL 4.4 066/174] media: davinci-isif: avoid uninitialized variable use Sasha Levin
2020-01-16 17:41 ` [PATCH AUTOSEL 4.4 078/174] media: ov2659: fix unbalanced mutex_lock/unlock Sasha Levin
2020-01-16 17:41 ` [PATCH AUTOSEL 4.4 086/174] media: omap_vout: potential buffer overflow in vidioc_dqbuf() Sasha Levin
2020-01-16 17:41 ` [PATCH AUTOSEL 4.4 087/174] media: davinci/vpbe: array underflow in vpbe_enum_outputs() Sasha Levin
2020-01-16 17:41 ` [PATCH AUTOSEL 4.4 099/174] media: vivid: fix incorrect assignment operation when setting video mode Sasha Levin
2020-01-16 17:42 ` [PATCH AUTOSEL 4.4 152/174] media: ov6650: Fix incorrect use of JPEG colorspace Sasha Levin
2020-01-16 17:42 ` [PATCH AUTOSEL 4.4 153/174] media: ov6650: Fix some format attributes not under control Sasha Levin
2020-01-16 17:42 ` [PATCH AUTOSEL 4.4 154/174] media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support Sasha Levin
2020-01-16 17:42 ` [PATCH AUTOSEL 4.4 161/174] media: exynos4-is: Fix recursive locking in isp_video_release() Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200116174251.24326-62-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hofrat@osadl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=sean@mess.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).