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: 2837587 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 4016E9F3B8 for ; Fri, 2 Aug 2013 09:15:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1856620208 for ; Fri, 2 Aug 2013 09:15:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 16523201DF for ; Fri, 2 Aug 2013 09:15:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758105Ab3HBJP2 (ORCPT ); Fri, 2 Aug 2013 05:15:28 -0400 Received: from mail-pb0-f47.google.com ([209.85.160.47]:57495 "EHLO mail-pb0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755010Ab3HBJP1 (ORCPT ); Fri, 2 Aug 2013 05:15:27 -0400 Received: by mail-pb0-f47.google.com with SMTP id rr4so468414pbb.6 for ; Fri, 02 Aug 2013 02:15:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=9IHsTx1H8W9BWWJlL1DnRBXGQk4/htcscUcvRcUPPvg=; b=Qb9Wq1JSmU+2sCOa5KVLjWpxbiJI3DM/iQzceDcow5m9hXc1GmVJFqIM/LjpvJM4zy DEgP8hx86XEgySF4ngSQp7oalqzkSrYGWwlpltVBGkdAI8eLRudckFj8CdlGVyjsrmEK AuAMJjLRydFsXa1jgrouLHMoSdOpTZcuHnt2I6XtGLlZ4pDln8oenk0IbJsQZ+05WI5W HsZOsiU7ceU5P3h/MDw5UA2opDMcxrVJ3F9yAjf5yRiGbd6p2J3JnjKT39IKk+vV+VMy zvjgDXURQsPB4QE9lKqQr1JtbPcUXwb+PIgyGW86kE9uCOm6+ofyJeEdOOJr7bYa83pS zvSQ== 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: ALoCoQk1wpv5klRI6GJVoFFUTHgkcLV6TdfYwCRVpBoeaFoso0gxfMoNZQoQqNWeoaMoCueTrpMr Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 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) {