From patchwork Fri Aug 2 08:58:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 18735 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 23581248E8 for ; Fri, 2 Aug 2013 09:15:29 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id m1sf508950ves.10 for ; Fri, 02 Aug 2013 02:15:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state:x-removed-original-auth: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=9IHsTx1H8W9BWWJlL1DnRBXGQk4/htcscUcvRcUPPvg=; b=gKSy4gepARQLHONbQmspWnhXktTeqaBNOt04J28Ba0UeuOW150GtLm1Gpnf4+DDIB1 g3eQybB0QO8vvbTFzlgQxb1rG6aBYt/Pm0D/ASXiuq5PM5OCCt8hnKJTP2Te0tWJXsHx mffjAOykCh8dM2tSy2JNwbHLZONOE/+c5fgKEmbAVhcTeCc+cwc8cJp3XbscO4HOcnhI 5kkpys08YM5esZzrBV6F4AE6u4qMIF3YbW5BbZCB3lzcuUJsGz9GLGwpecEkNv0R7AuD B0L1bnGv0hYjmEt4wUeaP2Y11m4B0q5UDwXJoFo0LhTY3EQu0H1hL9lq3+8f76oKRcSV xK/A== X-Received: by 10.236.137.35 with SMTP id x23mr2458995yhi.7.1375434928662; Fri, 02 Aug 2013 02:15:28 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.58.175 with SMTP id s15ls102466qeq.42.gmail; Fri, 02 Aug 2013 02:15:28 -0700 (PDT) X-Received: by 10.58.187.4 with SMTP id fo4mr1756590vec.55.1375434928552; Fri, 02 Aug 2013 02:15:28 -0700 (PDT) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id jf10si1658967vdb.37.2013.08.02.02.15.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:15:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.175 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.175; Received: by mail-ve0-f175.google.com with SMTP id oy10so382947veb.6 for ; Fri, 02 Aug 2013 02:15:28 -0700 (PDT) X-Received: by 10.221.43.70 with SMTP id ub6mr1671141vcb.86.1375434928424; Fri, 02 Aug 2013 02:15:28 -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.221.11.8 with SMTP id pc8csp346055vcb; Fri, 2 Aug 2013 02:15:27 -0700 (PDT) X-Received: by 10.68.242.105 with SMTP id wp9mr6523641pbc.153.1375434927441; Fri, 02 Aug 2013 02:15:27 -0700 (PDT) Received: from mail-pb0-f41.google.com (mail-pb0-f41.google.com [209.85.160.41]) by mx.google.com with ESMTPS id c10si6173436pav.200.2013.08.02.02.15.27 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:15:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.41 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.41; Received: by mail-pb0-f41.google.com with SMTP id rp2so470814pbb.14 for ; Fri, 02 Aug 2013 02:15:26 -0700 (PDT) X-Received: by 10.68.170.133 with SMTP id am5mr2479481pbc.104.1375434926837; Fri, 02 Aug 2013 02:15:26 -0700 (PDT) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id qh10sm9111563pbb.33.2013.08.02.02.15.24 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 02:15:26 -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 v2 3/3] [media] exynos4-is: Fix potential NULL pointer dereference Date: Fri, 2 Aug 2013 14:28:25 +0530 Message-Id: <1375433905-30369-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 X-Gm-Message-State: ALoCoQmk/Bw1xKNZr7wcEh7cxrnMOCZ2HoAYE948YZ2kuhxPaapK36VeqzMs2+7RIg/7Via1auQl X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: sachin.kamat@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.175 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: , dev->of_node could be NULL. Hence check for the same and return before dereferencing it in the subsequent error message. Signed-off-by: Sachin Kamat --- Changes since v1: Moved the NULL check to beginning of probe. --- drivers/media/platform/exynos4-is/fimc-lite.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c index 08fbfed..318d4c3 100644 --- a/drivers/media/platform/exynos4-is/fimc-lite.c +++ b/drivers/media/platform/exynos4-is/fimc-lite.c @@ -1504,16 +1504,17 @@ static int fimc_lite_probe(struct platform_device *pdev) struct resource *res; int ret; + if (!dev->of_node) + return -ENODEV; + fimc = devm_kzalloc(dev, sizeof(*fimc), GFP_KERNEL); if (!fimc) return -ENOMEM; - if (dev->of_node) { - of_id = of_match_node(flite_of_match, dev->of_node); - if (of_id) - drv_data = (struct flite_drvdata *)of_id->data; - fimc->index = of_alias_get_id(dev->of_node, "fimc-lite"); - } + of_id = of_match_node(flite_of_match, dev->of_node); + if (of_id) + drv_data = (struct flite_drvdata *)of_id->data; + fimc->index = of_alias_get_id(dev->of_node, "fimc-lite"); if (!drv_data || fimc->index >= drv_data->num_instances || fimc->index < 0) {