From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-eopbgr690092.outbound.protection.outlook.com ([40.107.69.92]:17633 "EHLO NAM04-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729985AbeIQI3A (ORCPT ); Mon, 17 Sep 2018 04:29:00 -0400 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Sylwester Nawrocki , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH AUTOSEL 4.14 24/87] media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt() Date: Mon, 17 Sep 2018 03:02:39 +0000 Message-ID: <20180917030220.245686-24-alexander.levin@microsoft.com> References: <20180917030220.245686-1-alexander.levin@microsoft.com> In-Reply-To: <20180917030220.245686-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Sylwester Nawrocki [ Upstream commit 7c1b9a5aeed91bef98988ac0fcf38c8c1f4f9a3a ] This patch fixes potential NULL pointer dereference as indicated by the following static checker warning: drivers/media/platform/exynos4-is/fimc-isp-video.c:408 isp_video_try_fmt_mp= lane() error: NULL dereference inside function '__isp_video_try_fmt(isp, &f->fmt.p= ix_mp, (0))()'. Fixes: 34947b8aebe3: ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA = driver") Reported-by: Dan Carpenter Signed-off-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/exynos4-is/fimc-isp-video.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-isp-video.c b/drivers/m= edia/platform/exynos4-is/fimc-isp-video.c index 55ba696b8cf4..a920164f53f1 100644 --- a/drivers/media/platform/exynos4-is/fimc-isp-video.c +++ b/drivers/media/platform/exynos4-is/fimc-isp-video.c @@ -384,12 +384,17 @@ static void __isp_video_try_fmt(struct fimc_isp *isp, struct v4l2_pix_format_mplane *pixm, const struct fimc_fmt **fmt) { - *fmt =3D fimc_isp_find_format(&pixm->pixelformat, NULL, 2); + const struct fimc_fmt *__fmt; + + __fmt =3D fimc_isp_find_format(&pixm->pixelformat, NULL, 2); + + if (fmt) + *fmt =3D __fmt; =20 pixm->colorspace =3D V4L2_COLORSPACE_SRGB; pixm->field =3D V4L2_FIELD_NONE; - pixm->num_planes =3D (*fmt)->memplanes; - pixm->pixelformat =3D (*fmt)->fourcc; + pixm->num_planes =3D __fmt->memplanes; + pixm->pixelformat =3D __fmt->fourcc; /* * TODO: double check with the docmentation these width/height * constraints are correct. --=20 2.17.1