From patchwork Tue Apr 26 09:15:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 8936871 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DB874BF29F for ; Tue, 26 Apr 2016 09:17:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 119372014A for ; Tue, 26 Apr 2016 09:17:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6366B201C7 for ; Tue, 26 Apr 2016 09:17:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752514AbcDZJQx (ORCPT ); Tue, 26 Apr 2016 05:16:53 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:50667 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751829AbcDZJQu (ORCPT ); Tue, 26 Apr 2016 05:16:50 -0400 Received: from wuerfel.lan. ([78.42.132.4]) by mrelayeu.kundenserver.de (mreue003) with ESMTPA (Nemesis) id 0M6hWa-1bgTRY2EJI-00wVev; Tue, 26 Apr 2016 11:16:04 +0200 From: Arnd Bergmann To: Mauro Carvalho Chehab Cc: Arnd Bergmann , Kukjin Kim , Krzysztof Kozlowski , Sylwester Nawrocki , Marek Szyprowski , Kamil Debski , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [media] exynos-gsc: avoid build warning without CONFIG_OF Date: Tue, 26 Apr 2016 11:15:38 +0200 Message-Id: <1461662157-1798157-1-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 2.7.0 X-Provags-ID: V03:K0:uNvMkw27WrkvxLJ0cGSy6lGGgE6jZVfLECWkv03rNbS33q9S+tq +GOjw4una0STwERBhXOiYwJce8CEnDYPKoUM+Kzpeq9Hs7f2NmnJWvSGs8t4bZvaKtikHvq rQDqisdTAvKlv0kaGzV3i4uwnyug0kMCHxxEaOYZdZZQVur4XX3tERMcDIOzGCnTK8DbGk4 DkWaJnY5ajGcLzm84IjPQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:4ld9rOy0MF8=:/HO0LAx1gvVOL8H+b2cMnA OQbe4BfJf0fj5oaTQB9WohgkzweDYEexNmedoWaTdJqPkRFqLnCW+wcJlni0aRNC+ZU5zkJrt rJDuwJ6qbrsRgheX0k5eF/+7O2BDu38jqMoCW7PRa4cUzvMWPhE2jyJs8E9csr3BchdL9LjI3 cbyRV1cRV7FfcuSCTXhmZ+1pkZz0WGafU7XLpebJhs7DiQpqLQxaD7Qg0Kti64Jk8iESnfsad X4XaBqsEBzyUv4EIhJ4Tp6XkPDQWESRjISaJStsFW5OsuRMQLvGwV1a60fLjvIFYEdQcUYWmo YcPlYT75Hxt/SOoUuhDJG+7NY8TxXhMDhfvOmB3mo1GnbWmRWMBXv3LGTP39dvN4Xu3/Ln+0L 4JLPzhsITITFmNztV0Qzhu9DI94fP6RsnlybWzp/NhKEnX58F2RE5ehAl8lRsURdAUuT6381w PWB/khKT+EsQm9V5j+6b//6KawAtp1eCzLHFYRqccMhfibidlT4T8/j8Mxs/9gYiD1zcX1xjt +PGXLHyN/bQqEB2fdbXeAMZXEcv7ABCmLq99w+1W4Ih8K49AHXG+JgXPM5x2v6lt0aKCz/YOv rRNg4HiHfHKkX5H9pw4Yx20bedA00eOP8Ct66YNBxuRHQyubtH8b4wNP2HWv48DtljHizW5qs PsxHcXV+XDMC4hTAK5/OR5HHcs5Ubw0erSVd8qp9aF3dl9gOrz6JI2Xzotr4PLsTClas= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When building the exynos-gsc driver with CONFIG_OF disabled, we get a warning about an out-of-bounds access: drivers/media/platform/exynos-gsc/gsc-core.c: In function 'gsc_probe': drivers/media/platform/exynos-gsc/gsc-core.c:1078:34: error: array subscript is above array bounds [-Werror=array-bounds] This is harmless because the driver will never be used without CONFIG_OF, but it's better to avoid the warning anyway. Checking the return value of of_alias_get_id() for an error condition is probably a good idea anyway, and it makes sure the compiler can verify that we don't get into that situation. Signed-off-by: Arnd Bergmann Fixes: 26a7ed9c1819 ("[media] exynos-gsc: remove an always false condition") --- drivers/media/platform/exynos-gsc/gsc-core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/exynos-gsc/gsc-core.c b/drivers/media/platform/exynos-gsc/gsc-core.c index c595723f5031..c04973669a47 100644 --- a/drivers/media/platform/exynos-gsc/gsc-core.c +++ b/drivers/media/platform/exynos-gsc/gsc-core.c @@ -1063,13 +1063,17 @@ static int gsc_probe(struct platform_device *pdev) struct resource *res; struct gsc_driverdata *drv_data = gsc_get_drv_data(pdev); struct device *dev = &pdev->dev; - int ret = 0; + int ret; gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL); if (!gsc) return -ENOMEM; - gsc->id = of_alias_get_id(pdev->dev.of_node, "gsc"); + ret = of_alias_get_id(pdev->dev.of_node, "gsc"); + if (ret < 0) + return ret; + + gsc->id = ret; if (gsc->id >= drv_data->num_entities) { dev_err(dev, "Invalid platform device id: %d\n", gsc->id); return -EINVAL;