From patchwork Mon Apr 15 12:03:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 16135 Return-Path: X-Original-To: linaro@staging.patches.linaro.org Delivered-To: linaro@staging.patches.linaro.org Received: from mail-qa0-f72.google.com (mail-qa0-f72.google.com [209.85.216.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id BC76E2395C for ; Mon, 15 Apr 2013 12:16:43 +0000 (UTC) Received: by mail-qa0-f72.google.com with SMTP id bn16sf717392qab.3 for ; Mon, 15 Apr 2013 05:16:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=xnP54JMVWHHGj/HKdZeZs2p8jaqFMF5U+u2eTCyLQYw=; b=GjBMcZdbRwwiEfGyrFQFElp+8/WcW+M8M7ah6866+UsgVEQtz95N2wXgl5yIg7ywlU h2qz4VWylDYL+6Z/6l4Zler84rskJI1p7Efvzg+dUnFsgK5VG6Jrjr4STVU2AVG+fkpT wsH51UigTb12smvSiXBBrJpwriCeC8pOAuRCpcS+NtJEjyBKmlsWy9mKvJYiFw9jvVq2 sOwZ0+42IYXLkHpJKD6lU170IB2mrl0VaC8fHgiqitszKt1xKKrsI1Z8KEv2Vm0mPw7h zIC606L2VnZWAjn3VMJ0nzwsxMu3NL0h3L7myIDYXThz9myv9y9i/6wpzXJysdiRiLxv 7bow== X-Received: by 10.58.202.41 with SMTP id kf9mr8833201vec.11.1366028172873; Mon, 15 Apr 2013 05:16:12 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.39 with SMTP id e7ls2493148qej.58.gmail; Mon, 15 Apr 2013 05:16:12 -0700 (PDT) X-Received: by 10.58.90.66 with SMTP id bu2mr15835883veb.29.1366028172702; Mon, 15 Apr 2013 05:16:12 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id da5si12962783vdc.115.2013.04.15.05.16.12 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 05:16:12 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id gf12so3088808vcb.4 for ; Mon, 15 Apr 2013 05:16:12 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr13515836vdb.94.1366028172563; Mon, 15 Apr 2013 05:16:12 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp164385veb; Mon, 15 Apr 2013 05:16:11 -0700 (PDT) X-Received: by 10.66.246.168 with SMTP id xx8mr29151397pac.107.1366028171011; Mon, 15 Apr 2013 05:16:11 -0700 (PDT) Received: from mail-pb0-f53.google.com (mail-pb0-f53.google.com [209.85.160.53]) by mx.google.com with ESMTPS id wn1si19347807pbc.51.2013.04.15.05.16.10 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 05:16:11 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.53 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.53; Received: by mail-pb0-f53.google.com with SMTP id un15so2479932pbc.12 for ; Mon, 15 Apr 2013 05:16:10 -0700 (PDT) X-Received: by 10.66.163.229 with SMTP id yl5mr29241813pab.104.1366028170273; Mon, 15 Apr 2013 05:16:10 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPS id ba10sm20148470pbd.21.2013.04.15.05.16.07 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Apr 2013 05:16:09 -0700 (PDT) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: s.nawrocki@samsung.com, sachin.kamat@linaro.org, patches@linaro.org Subject: [PATCH 1/1] [media] exynos4-is: Fix potential null pointer dereferencing Date: Mon, 15 Apr 2013 17:33:58 +0530 Message-Id: <1366027438-4560-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQklbJVgTg6Uz4iVKPxrQw7l5acOxwuQHv74i9makp8eMErmhAUUJSEwGOEq24cZheCcA5rr X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.173 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , If fimc->drv_data is NULL, then fimc->drv_data->num_entities would cause NULL pointer dereferencing. While at it also remove the check for fimc->id being negative as 'id' is unsigned variable and can't be less than 0. Signed-off-by: Sachin Kamat --- drivers/media/platform/exynos4-is/fimc-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-core.c b/drivers/media/platform/exynos4-is/fimc-core.c index f25807d..d388832 100644 --- a/drivers/media/platform/exynos4-is/fimc-core.c +++ b/drivers/media/platform/exynos4-is/fimc-core.c @@ -953,10 +953,9 @@ static int fimc_probe(struct platform_device *pdev) fimc->drv_data = fimc_get_drvdata(pdev); fimc->id = pdev->id; } - if (!fimc->drv_data || fimc->id >= fimc->drv_data->num_entities || - fimc->id < 0) { - dev_err(dev, "Invalid driver data or device id (%d/%d)\n", - fimc->id, fimc->drv_data->num_entities); + if (!fimc->drv_data || fimc->id >= fimc->drv_data->num_entities) { + dev_err(dev, "Invalid driver data or device id (%d)\n", + fimc->id); return -EINVAL; } if (!dev->of_node)