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: 2444761 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 130E4DF2E5 for ; Mon, 15 Apr 2013 12:16:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932109Ab3DOMQL (ORCPT ); Mon, 15 Apr 2013 08:16:11 -0400 Received: from mail-pa0-f52.google.com ([209.85.220.52]:56438 "EHLO mail-pa0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753449Ab3DOMQL (ORCPT ); Mon, 15 Apr 2013 08:16:11 -0400 Received: by mail-pa0-f52.google.com with SMTP id fb10so2523700pad.39 for ; Mon, 15 Apr 2013 05:16:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=xnP54JMVWHHGj/HKdZeZs2p8jaqFMF5U+u2eTCyLQYw=; b=I2/5uo4MxgphWz37pc0ZsYpgZ6reKEKrYnOlx+pVPicF8yVAfnCJTBRAm2xkJvbvoM WRkFoiR4a8l1H+luZzUrMoE9E/RatFdfExXE79+6IL21V+w5EJ4w7xp+HhCCwEHr4DLq W3fHHxUIWZ0GbDtgaZea/uorAnhLNdb4L8ynO6mNdT+6KadP4Ck4Lwp3GbaXNk1jvxjo jGccG2OwUk8Ejo/U/pvciPu8l8oMs9kcLMemmsaQ8+/DjtNZC/Ddf0GZIowR5Zu6quKZ W5zsaHn7h+4wSqWdCxCYDebluaWYp3aeEgLrS3mzHhhwOeDXriOejbJfHpLoIttqwidv 6/BQ== 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: ALoCoQlACxmip+oXmj0NbCF+FXSaMh0FoTtP3YA4PrKPDz52svdWLQdtZjodnOcXYWyu3C+agSyO Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org 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)