From patchwork Wed Nov 21 06:20:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1778291 X-Patchwork-Delegate: jikos@jikos.cz Return-Path: X-Original-To: patchwork-linux-input@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6BE013FC23 for ; Wed, 21 Nov 2012 06:26:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751002Ab2KUG0u (ORCPT ); Wed, 21 Nov 2012 01:26:50 -0500 Received: from mail-pa0-f46.google.com ([209.85.220.46]:59725 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750995Ab2KUG0u (ORCPT ); Wed, 21 Nov 2012 01:26:50 -0500 Received: by mail-pa0-f46.google.com with SMTP id bh2so1840080pad.19 for ; Tue, 20 Nov 2012 22:26:50 -0800 (PST) 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:in-reply-to:references :x-gm-message-state; bh=faPhlGwSsfXXsWwkOVg8MmiRhIA6KBGUUd81j+FErRw=; b=I4sFraEt6uERpHfpxOZ9rDAkWyJ1rUc1CKVNt9oFuc9sIQQlP5J0EnMMgS11FsJ2uv 7+KnEHKxn/NJiiUQdM2OyVduRuWQdofrrMesXq7C0GwwObxkMZDuYuqD68HL6+qjBTsL lOvrL/4MxakG4tz5kmZq6fTP7f32HlOuPXNs8h498ecVs9vmp0Gvd1A2t75L36jh/Hkw EniFKej0svHv2ViLpboAU26CzRCO6Mxa7zjctc1/BPSnoqUC3Mj+zkgDJ4yzzTzCWRkN LWSDX+wewAIkIqznYEgac1ofaByCqSzh3cCA+pnExXOgPCUsBZTgXe484/71gKAMT84F lkKA== Received: by 10.66.85.10 with SMTP id d10mr15061909paz.52.1353479210260; Tue, 20 Nov 2012 22:26:50 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id os5sm9383907pbc.15.2012.11.20.22.26.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 22:26:49 -0800 (PST) From: Sachin Kamat To: linux-input@vger.kernel.org Cc: jkosina@suse.cz, jic23@kernel.org, sachin.kamat@linaro.org, patches@linaro.org, Srinivas Pandruvada Subject: [PATCH 2/2] hid: hid-sensor-hub: Move NULL check to beginning Date: Wed, 21 Nov 2012 11:50:30 +0530 Message-Id: <1353478830-23788-2-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353478830-23788-1-git-send-email-sachin.kamat@linaro.org> References: <1353478830-23788-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQm8u7bLadtTfrgB8ewag+BdhoIeBbTUWAWnF9KLdIj+kA1CQ4DfWNhSooguoiuAUO2rmUGH Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org This avoids a possible NULL pointer dereference error when report is NULL. Cc: Srinivas Pandruvada Signed-off-by: Sachin Kamat --- drivers/hid/hid-sensor-hub.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index d9d73e9..29f8071 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -428,6 +428,9 @@ static int sensor_hub_raw_event(struct hid_device *hdev, struct hid_collection *collection = NULL; void *priv = NULL; + if (!report) + goto err_report; + hid_dbg(hdev, "sensor_hub_raw_event report id:0x%x size:%d type:%d\n", report->id, size, report->type); hid_dbg(hdev, "maxfield:%d\n", report->maxfield); @@ -437,9 +440,6 @@ static int sensor_hub_raw_event(struct hid_device *hdev, ptr = raw_data; ptr++; /*Skip report id*/ - if (!report) - goto err_report; - spin_lock_irqsave(&pdata->lock, flags); for (i = 0; i < report->maxfield; ++i) {