From patchwork Tue May 15 09:21:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sylwester Nawrocki/Kernel \\(PLT\\) /SRPOL/Staff Engineer/Samsung Electronics" X-Patchwork-Id: 10400681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8E1DE601C8 for ; Tue, 15 May 2018 09:22:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71DC9286F8 for ; Tue, 15 May 2018 09:22:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 660DF286FB; Tue, 15 May 2018 09:22:10 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 05BE9286F8 for ; Tue, 15 May 2018 09:22:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752349AbeEOJWH (ORCPT ); Tue, 15 May 2018 05:22:07 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:38495 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752226AbeEOJWG (ORCPT ); Tue, 15 May 2018 05:22:06 -0400 Received: from epcas2p4.samsung.com (unknown [182.195.41.56]) by mailout1.samsung.com (KnoxPortal) with ESMTP id 20180515092204epoutp0100a0f3f927011d61b58d2e1e132094d3~uxv9-ThN_0894808948epoutp01V; Tue, 15 May 2018 09:22:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.samsung.com 20180515092204epoutp0100a0f3f927011d61b58d2e1e132094d3~uxv9-ThN_0894808948epoutp01V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1526376124; bh=U6sNBe1FPUI39Z/UdCl2zTMnOVFpSPlNXFgnMJshEio=; h=From:To:Cc:Subject:Date:References:From; b=T6zJEauIACOVYJ+5j1NEBbLLGu3bjXQGwsvPVy9sI4MFd+cFgDUAHMeMO33KZF9Lo SKHbuzszNDZpIU0Wauk8ytNIb0ay6j9yBudn8ljt4IZvK0S7QtWtlMg/at6hBYUi6y X0uEGhtNydtiQ1oxNkek0OCOlTzOUiJKhrdWI8aA= Received: from epsmges2p1.samsung.com (unknown [182.195.42.69]) by epcas2p2.samsung.com (KnoxPortal) with ESMTP id 20180515092204epcas2p25e624869745aa9c65399af57a6f6657e~uxv932KKY1711517115epcas2p2Z; Tue, 15 May 2018 09:22:04 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p1.samsung.com (Symantec Messaging Gateway) with SMTP id 9D.C8.04128.CB6AAFA5; Tue, 15 May 2018 18:22:04 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p4.samsung.com (KnoxPortal) with ESMTP id 20180515092203epcas2p4a97c179cbba250cf45c1527a5e00735c~uxv9lnsX_3047630476epcas2p4J; Tue, 15 May 2018 09:22:03 +0000 (GMT) X-AuditID: b6c32a45-8f3ff70000001020-da-5afaa6bc2b87 Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id AE.38.03817.BB6AAFA5; Tue, 15 May 2018 18:22:03 +0900 (KST) Received: from AMDC3061.digital.local ([106.116.147.40]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P8R0077VJCCMPA0@mmp1.samsung.com>; Tue, 15 May 2018 18:22:03 +0900 (KST) From: Sylwester Nawrocki To: linux-media@vger.kernel.org Cc: dan.carpenter@oracle.com, linux-samsung-soc@vger.kernel.org, Sylwester Nawrocki Subject: [PATCH] exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt() Date: Tue, 15 May 2018 11:21:45 +0200 Message-id: <20180515092145.6161-1-s.nawrocki@samsung.com> X-Mailer: git-send-email 2.14.2 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupjkeLIzCtJLcpLzFFi42LZdljTTHfPsl9RBrsvc1u8/jedxaJnw1ZW ixnn9zFZHH7TzurA4vHx6S0Wj74tqxg9Pm+SC2CO4rJJSc3JLEst0rdL4MroereRvWAvT8Wf HUeYGxjvc3UxcnJICJhIHPi8krmLkYtDSGAHo8Syk0/YIJzvjBLHH85kgqk6/PUUC0RiN6NE w9G/7BDOL0aJy6/a2ECq2AQMJXqP9jGC2CIC8hJPem+AxZkF8iS6Xq9mBrGFBSIkbjU8YgGx WQRUJdasfQNWwytgJbF26Wt2iG3yEu8X3GcEWSAhcJJVomfWeaiEi8TK5WtYIGxhiVfHt0DF pSWerdrICGFXS3S2dbFDNLcwSvyZdokNImEtcfj4RVaIi/gkOg6DvMABFOeV6GgTgjA9JL59 jYSodpS4uv8O2EghgViJi3fXsk9glFzAyLCKUSy1oDg3PbXYqMBQrzgxt7g0L10vOT93EyM4 lrRcdzDOOOdziFGAg1GJhzdh2s8oIdbEsuLK3EOMEhzMSiK8u42AQrwpiZVVqUX58UWlOanF hxilOViUxHnXKH2NEhJITyxJzU5NLUgtgskycXBKNTDG2l6R6giqaUkqiPmu9udx85a1mrNq 9qt/z3/H3XyoaI/xtDXfTqxTsxfruhV8frLOn0lfj2Y1OZwQvpupOMM9VWz2UZb5lXI+jiW/ ql3fqES4S3dVNd2NW/L83uIHn1faPjpxKJD72+vDyh1Lv1eovatV0L39W5mx0izj556KOsb1 Ive5xGSVWIozEg21mIuKEwHtC+mYoQIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrNJMWRmVeSWpSXmKPExsVy+t9jAd3dy35FGTQvNrd4/W86i0XPhq2s FjPO72OyOPymndWBxePj01ssHn1bVjF6fN4kF8AcxWWTkpqTWZZapG+XwJXR9W4je8Fenoo/ O44wNzDe5+pi5OSQEDCROPz1FEsXIxeHkMBORolrW/6xQTi/GCUap2xmA6liEzCU6D3axwhi iwjISzzpvQEWZxbIk7j0YTqYLSwQIXGr4RELiM0ioCqxZu0bsDivgJXE2qWv2SG2yUu8X3Cf cQIj1wJGhlWMkqkFxbnpucVGBUZ5qeV6xYm5xaV56XrJ+bmbGIFe3nZYq38H4+Ml8YcYBTgY lXh4E6b9jBJiTSwrrsw9xCjBwawkwrvbCCjEm5JYWZValB9fVJqTWnyIUZqDRUmclz//WKSQ QHpiSWp2ampBahFMlomDU6qBcV185EfFVUtPi4Xmuur+KEosn3ttSqLGus9+V81tzpfbzLP8 4nZnm1gzX9WnVSlJB/ZLCigxycQsO31ySlHm3vhzzx1kZNn9Vpc1x1tkCa7/8qP1zuymMFc2 5YvRJUKTGipKHF3mnyp2nMQf8vnInXzR18IJy9WlxdKCHVaw3JFSDr7vsFhCiaU4I9FQi7mo OBEAh7kymu4BAAA= X-CMS-MailID: 20180515092203epcas2p4a97c179cbba250cf45c1527a5e00735c X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180515092203epcas2p4a97c179cbba250cf45c1527a5e00735c X-RootMTR: 20180515092203epcas2p4a97c179cbba250cf45c1527a5e00735c References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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_mplane() error: NULL dereference inside function '__isp_video_try_fmt(isp, &f->fmt.pix_mp, (0))()'. Fixes: 34947b8aebe3: ("[media] exynos4-is: Add the FIMC-IS ISP capture DMA driver") Reported-by: Dan Carpenter Signed-off-by: Sylwester Nawrocki --- 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/media/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 = fimc_isp_find_format(&pixm->pixelformat, NULL, 2); + const struct fimc_fmt *__fmt; + + __fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2); + + if (fmt) + *fmt = __fmt; pixm->colorspace = V4L2_COLORSPACE_SRGB; pixm->field = V4L2_FIELD_NONE; - pixm->num_planes = (*fmt)->memplanes; - pixm->pixelformat = (*fmt)->fourcc; + pixm->num_planes = __fmt->memplanes; + pixm->pixelformat = __fmt->fourcc; /* * TODO: double check with the docmentation these width/height * constraints are correct.