From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 650F91C1723; Tue, 27 Aug 2024 15:24:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724772274; cv=none; b=VKsQdkQqhEeX1q8Kk0NP8axF4DID2xzdxisg2aEpxjPSpbyqHMWnRMS8hOAWFzlKrbKxnSjbOdFH5rSiT1iUyl0ZomA+VKZcbYmloGGiXHB/2E7mP/qOlK0LBDZSAaFVHKye/RFAyATXoT/F2TUSTkmJR8ZOVneG+BhPdpw9Noo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724772274; c=relaxed/simple; bh=qP2D/zMaRY+kv6+uvQuJuN7wpQsmwYJTVs0fpdlK7fE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=a22bg98eN69TUXY3OSbYfwCq9TxKDs89HLvNb/3vt1N/I//FvLETBu6oUAwCHlnTCpX5Zhjvp3evdhnC3LgMBydADw1ujSjs101L2+MXYoZaxJauWVcQUaAQ8tEtyMJA0NiVAaiNRn19uUf6QkMftrSdoAEttfqYH0HKj5QwIfI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xoue8cMF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xoue8cMF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C90FAC61076; Tue, 27 Aug 2024 15:24:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1724772274; bh=qP2D/zMaRY+kv6+uvQuJuN7wpQsmwYJTVs0fpdlK7fE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xoue8cMFz1jN57qr8Tz2A2tPRkfJ2d/7a60LtZ4Y34zHmsX9tTPP72JDLbFr/Pb0n GYtiVQgPpgOunS7M6BhcHRdO9VxYkc3b71E8YnCt5WEdaTnKmnLMB25shK5iHdyLOj 53o9nomYyveQG/1y3EaRssNUNAiec8ujdQ+Axyk8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Hans Verkuil , Sicong Huang , Sasha Levin Subject: [PATCH 6.1 164/321] media: pci: cx23885: check cx23885_vdev_init() return Date: Tue, 27 Aug 2024 16:37:52 +0200 Message-ID: <20240827143844.473154659@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240827143838.192435816@linuxfoundation.org> References: <20240827143838.192435816@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans Verkuil [ Upstream commit 15126b916e39b0cb67026b0af3c014bfeb1f76b3 ] cx23885_vdev_init() can return a NULL pointer, but that pointer is used in the next line without a check. Add a NULL pointer check and go to the error unwind if it is NULL. Signed-off-by: Hans Verkuil Reported-by: Sicong Huang Signed-off-by: Sasha Levin --- drivers/media/pci/cx23885/cx23885-video.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index 9af2c5596121c..51d7d720ec48b 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c @@ -1354,6 +1354,10 @@ int cx23885_video_register(struct cx23885_dev *dev) /* register Video device */ dev->video_dev = cx23885_vdev_init(dev, dev->pci, &cx23885_video_template, "video"); + if (!dev->video_dev) { + err = -ENOMEM; + goto fail_unreg; + } dev->video_dev->queue = &dev->vb2_vidq; dev->video_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO | V4L2_CAP_VIDEO_CAPTURE; @@ -1382,6 +1386,10 @@ int cx23885_video_register(struct cx23885_dev *dev) /* register VBI device */ dev->vbi_dev = cx23885_vdev_init(dev, dev->pci, &cx23885_vbi_template, "vbi"); + if (!dev->vbi_dev) { + err = -ENOMEM; + goto fail_unreg; + } dev->vbi_dev->queue = &dev->vb2_vbiq; dev->vbi_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | V4L2_CAP_AUDIO | V4L2_CAP_VBI_CAPTURE; -- 2.43.0