From patchwork Tue May 8 08:42:05 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: 10385743 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 3078760236 for ; Tue, 8 May 2018 08:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22F9728B0C for ; Tue, 8 May 2018 08:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1748F28B83; Tue, 8 May 2018 08:42:20 +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=-7.8 required=2.0 tests=BAYES_00,BIGNUM_EMAILS, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 AC34D28B6B for ; Tue, 8 May 2018 08:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932548AbeEHImP (ORCPT ); Tue, 8 May 2018 04:42:15 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:40123 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932484AbeEHImL (ORCPT ); Tue, 8 May 2018 04:42:11 -0400 Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20180508084209epoutp03822b158488e8705adedd51fba0a5433f~snsHu_RJ62045020450epoutp035; Tue, 8 May 2018 08:42:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout3.samsung.com 20180508084209epoutp03822b158488e8705adedd51fba0a5433f~snsHu_RJ62045020450epoutp035 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1525768929; bh=8y2p1rboQG/0SNUYgTP30DuEiWbdzX3RBb54RXa0wOM=; h=Subject:To:Cc:From:Date:In-reply-to:References:From; b=nTnqHgitjAeVWo7QghDjocivPtTCImCk62qQNdWGE5T/bvG9sFw7iEu46uV2CqhGT DFoja5CZ/k7arjil6mJgTqn8hCWRbtXmUUpxcwCsZJtS/x6mMfHG87gGrD5zYUP5jL QXWuPkXh9/UUDd/rOHRZCVRtXKljXuWBGBrCPZVU= Received: from epsmges2p2.samsung.com (unknown [182.195.42.70]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180508084209epcas2p3067e1d8f6e51a4b6a7a3b7c519df757d~snsHiD2mJ0769907699epcas2p3h; Tue, 8 May 2018 08:42:09 +0000 (GMT) Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p2.samsung.com (Symantec Messaging Gateway) with SMTP id 4B.CC.04132.1E261FA5; Tue, 8 May 2018 17:42:09 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20180508084208epcas2p1695400fdfea3ec053aaf09e5950efeff~snsHMx3T61898218982epcas2p1J; Tue, 8 May 2018 08:42:08 +0000 (GMT) X-AuditID: b6c32a46-145ff70000001024-3d-5af162e12e7e Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 1B.2D.03817.0E261FA5; Tue, 8 May 2018 17:42:08 +0900 (KST) Received: from [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 <0P8E00FUOIU6ZJ70@mmp1.samsung.com>; Tue, 08 May 2018 17:42:08 +0900 (KST) Subject: Re: [bug report] [media] exynos4-is: Add the FIMC-IS ISP capture DMA driver To: Dan Carpenter Cc: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org From: Sylwester Nawrocki Message-id: Date: Tue, 08 May 2018 10:42:05 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-version: 1.0 In-reply-to: <20180503114301.GA7576@mwanda> Content-type: text/plain; charset="utf-8" Content-language: en-GB Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPIsWRmVeSWpSXmKPExsWy7bCmue7DpI9RBt07eC1e/5vOYtGzYSur xYzz+5gcmD0+Pr3F4vF5k1wAUxSXTUpqTmZZapG+XQJXxuK1zUwFk2UqjrzfwNTAOFu4i5GT Q0LARGLVvxeMXYxcHEICOxgllu+dyQ7hfGeU+POojaWLkQOs6sc3EYj4bkaJqac/Q3XcZ5Ro 3b+cEWSUsECYxKuD7awgtoiAjsTlzh/sIDazgJPEn39nwGrYBAwleo/2gdm8AnYSNw/NALNZ BFQlbi7ZClYvKhAh0fT8JztEjaDEj8n3WEBsTgFtieUvfjJBzNSUePFlEguELS5x7P5NRghb XmLzmrfMEK/NYZO4dM0GwnaReH3+MTuELSzx6vgWKFta4tmqjYwQdrVEZ1sX2PcSAi1A30+7 xAaRsJY4fPwiK8QCPomOw3/ZIaHCK9HRJgRR4iGx89wlqL2OEu+eLQYrFxKok3h3fxXTBEa5 WUjemYXkhVlIXpiF5IUFjCyrGMVSC4pz01OLjQqM9IoTc4tL89L1kvNzNzGCk4GW2w7GJed8 DjEKcDAq8fAGFH+IEmJNLCuuzD3EKMHBrCTCqyz7MUqINyWxsiq1KD++qDQntfgQozQHi5I4 b4PvmSghgfTEktTs1NSC1CKYLBMHp1QDo+E/5zezRF304w0NuvM3XJvYZXRxMcuKCBW756c5 p6xZJvj6Qe2nM+EiYsFyDy62ZFenvd9+kWuR4ZFbUXsSrq8s8ev4Me2h85LZR2YG/kua5DD/ nFepgbvV10fN7NphbW13mbxU71Sp7VB5K3L3cB/TBoG81Zxrgr/Y197jXsNQKCrrY2HoqcRS nJFoqMVcVJwIAGNC5+oCAwAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrOLMWRmVeSWpSXmKPExsVy+t9jAd0HSR+jDFYvNLV4/W86i0XPhq2s FjPO72NyYPb4+PQWi8fnTXIBTFFcNimpOZllqUX6dglcGYvXNjMVTJapOPJ+A1MD42zhLkYO DgkBE4kf30S6GLk4hAR2Mkr8mXqIHcJ5COQcucjaxcjJISwQJvF49UYmEFtEQEficucPdhCb WcBJ4s+/M4wQDQ2MEpf2rARLsAkYSvQe7WMEsXkF7CRuHpoBZrMIqErcXLIVrEZUIELi3vlP bBA1ghI/Jt9jAbE5BbQllr/4yQRyHbOAusSUKbkQu8Qljt2/yQhhy0tsXvOWeQKjwCwk3bMQ OmYh6ZiFpGMBI8sqRsnUguLc9NxiowKjvNRyveLE3OLSvHS95PzcTYzA4N12WKt/B+PjJfGH GAU4GJV4eH8UfIgSYk0sK67MPcQowcGsJMKrLPsxSog3JbGyKrUoP76oNCe1+BCjNAeLkjgv f/6xSCGB9MSS1OzU1ILUIpgsEwenVANj+MzvD3bx/2v/k7dTNp1/2jGjRzdyTzAvCM9dyy0m r7A4LvHYNPYZLnZ3bxlzrY1Q6Ph++WGKvqi3fe1DFsa57bMLeGX2KSyayBjc6+buWZhzyUDZ XmaXe85O3wz9hxeOFdUVdUnbyLrq3U9n/vfq88WNparR3wVreoTWzfXYONn0266uHTVKLMUZ iYZazEXFiQCMCSRBWgIAAA== X-CMS-MailID: 20180508084208epcas2p1695400fdfea3ec053aaf09e5950efeff X-Msg-Generator: CA CMS-TYPE: 102P X-CMS-RootMailID: 20180503114314epcas2p3a468e807db4c04b2f42b904c530d8565 X-RootMTR: 20180503114314epcas2p3a468e807db4c04b2f42b904c530d8565 References: <20180503114301.GA7576@mwanda> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 05/03/2018 01:43 PM, Dan Carpenter wrote: > [ This code is five years old now. It's so weird to me that the warning > is showing up in my new warnings pile. Perhaps this wasn't included > in my allmodconfig before? - dan ] Might be, the bug found is real. The module is normally disabled anyway for other reasons. > Hello Sylwester Nawrocki, > > The patch 34947b8aebe3: "[media] exynos4-is: Add the FIMC-IS ISP > capture DMA driver" from Dec 20, 2013, leads to 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))()'. > > drivers/media/platform/exynos4-is/fimc-isp-video.c > 383 static void __isp_video_try_fmt(struct fimc_isp *isp, > 384 struct v4l2_pix_format_mplane *pixm, > 385 const struct fimc_fmt **fmt) > 386 { > 387 *fmt = fimc_isp_find_format(&pixm->pixelformat, NULL, 2); > ^^^^ > Unchecked dereference. We're not allowed to pass a NULL "fmt". > > 388 > 389 pixm->colorspace = V4L2_COLORSPACE_SRGB; > 390 pixm->field = V4L2_FIELD_NONE; > 391 pixm->num_planes = (*fmt)->memplanes; > 392 pixm->pixelformat = (*fmt)->fourcc; > 393 /* > 394 * TODO: double check with the docmentation these width/height > 395 * constraints are correct. > 396 */ > 397 v4l_bound_align_image(&pixm->width, FIMC_ISP_SOURCE_WIDTH_MIN, > 398 FIMC_ISP_SOURCE_WIDTH_MAX, 3, > 399 &pixm->height, FIMC_ISP_SOURCE_HEIGHT_MIN, > 400 FIMC_ISP_SOURCE_HEIGHT_MAX, 0, 0); > 401 } > 402 > 403 static int isp_video_try_fmt_mplane(struct file *file, void *fh, > 404 struct v4l2_format *f) > 405 { > 406 struct fimc_isp *isp = video_drvdata(file); > 407 > 408 __isp_video_try_fmt(isp, &f->fmt.pix_mp, NULL); > ^^^^ > And yet here we are. > > 409 return 0; > 410 } We may need something like: ----8<---- ----8<---- I will post the patch to clear the warning. 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.