From patchwork Sat Oct 13 11:41:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 12209 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 9AA2524188 for ; Sat, 13 Oct 2012 11:45:51 +0000 (UTC) Received: from mail-ia0-f180.google.com (mail-ia0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2CD08A18B4A for ; Sat, 13 Oct 2012 11:45:51 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id f6so2585503iag.11 for ; Sat, 13 Oct 2012 04:45:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:x-gm-message-state; bh=zQPzNQ5C1iOb1tEq/LB/oKNfDZ1hfcnVX817qdVP98A=; b=YlmDmrMe7jLMIaYLx4pa0Jj5JvRjG2Tg5DIOla24wiI+N50Y6iM3iKJHruwC8CEne3 +aDdJP4y2cXOrapcVqFI+ns+UVnYYHqXyAVT47AezrL6xNZk007FKwCQaq2Xlo2wrSqe 8oBUgI+NlDfFAMeMsDA/QERXWpC1377eD6rUY3ONGPl+XQjQVxiM1HQ77qjr1kBxfN5m 83tgCu6/3yNQbjB0+g5DH4+8BAHtvXy0xneb5msM4Nnp607Z8qpyVGPpw9+Tm8gB+WVC EPTLZXvTjmb9r24sca41Aeh7+vaeAuGgZOTafGQ5H+6/U/1tCZHJmCiNSuHmppqKCFhp 0ZjQ== Received: by 10.42.145.66 with SMTP id e2mr5281491icv.18.1350128750395; Sat, 13 Oct 2012 04:45:50 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp325695igt; Sat, 13 Oct 2012 04:45:48 -0700 (PDT) Received: by 10.66.89.37 with SMTP id bl5mr18505909pab.55.1350128748233; Sat, 13 Oct 2012 04:45:48 -0700 (PDT) Received: from mail-da0-f50.google.com (mail-da0-f50.google.com [209.85.210.50]) by mx.google.com with ESMTPS id ho10si15201895pbc.120.2012.10.13.04.45.47 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 13 Oct 2012 04:45:48 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.210.50; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.210.50 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-da0-f50.google.com with SMTP id z20so1998981dae.37 for ; Sat, 13 Oct 2012 04:45:47 -0700 (PDT) Received: by 10.66.78.231 with SMTP id e7mr18427333pax.44.1350128747567; Sat, 13 Oct 2012 04:45:47 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id rw5sm5940446pbc.54.2012.10.13.04.45.44 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 13 Oct 2012 04:45:46 -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] s5p-fimc: Fix potential NULL pointer dereference Date: Sat, 13 Oct 2012 17:11:19 +0530 Message-Id: <1350128479-9619-1-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 X-Gm-Message-State: ALoCoQlUJbyg0LYYn1J9gPwbXdBNcwiik4r9++3qWFzCvEFrd2WUuuAHdtlkelGeqfgfRy6EYEv/ 'fimc' was being dereferenced before the NULL check. Moved it to after the check. Signed-off-by: Sachin Kamat --- drivers/media/platform/s5p-fimc/fimc-mdevice.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s5p-fimc/fimc-mdevice.c b/drivers/media/platform/s5p-fimc/fimc-mdevice.c index 80ada58..61fab00 100644 --- a/drivers/media/platform/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/platform/s5p-fimc/fimc-mdevice.c @@ -343,7 +343,7 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) static int fimc_register_callback(struct device *dev, void *p) { struct fimc_dev *fimc = dev_get_drvdata(dev); - struct v4l2_subdev *sd = &fimc->vid_cap.subdev; + struct v4l2_subdev *sd; struct fimc_md *fmd = p; int ret = 0; @@ -353,6 +353,7 @@ static int fimc_register_callback(struct device *dev, void *p) if (fimc->pdev->id < 0 || fimc->pdev->id >= FIMC_MAX_DEVS) return 0; + sd = &fimc->vid_cap.subdev; fimc->pipeline_ops = &fimc_pipeline_ops; fmd->fimc[fimc->pdev->id] = fimc; sd->grp_id = FIMC_GROUP_ID; @@ -369,7 +370,7 @@ static int fimc_register_callback(struct device *dev, void *p) static int fimc_lite_register_callback(struct device *dev, void *p) { struct fimc_lite *fimc = dev_get_drvdata(dev); - struct v4l2_subdev *sd = &fimc->subdev; + struct v4l2_subdev *sd; struct fimc_md *fmd = p; int ret; @@ -379,6 +380,7 @@ static int fimc_lite_register_callback(struct device *dev, void *p) if (fimc->index >= FIMC_LITE_MAX_DEVS) return 0; + sd = &fimc->subdev; fimc->pipeline_ops = &fimc_pipeline_ops; fmd->fimc_lite[fimc->index] = fimc; sd->grp_id = FLITE_GROUP_ID;