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: 13026 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 2012D23FC9 for ; Wed, 21 Nov 2012 06:26:52 +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 C7825A182A3 for ; Wed, 21 Nov 2012 06:26:51 +0000 (UTC) Received: by mail-ia0-f180.google.com with SMTP id t4so2281286iag.11 for ; Tue, 20 Nov 2012 22:26:51 -0800 (PST) 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:in-reply-to:references :x-gm-message-state; bh=faPhlGwSsfXXsWwkOVg8MmiRhIA6KBGUUd81j+FErRw=; b=BoOT+n8z3teSdWEeA0lZ7d0Vr9DJcVpBsUSU671M0Pdg5BuLFssk2p7ZjYByfUDHe+ z57h867r4o4reCorRgp6cCAs0WIMiu8jWkfyU9q+dQCc+4zE7RlaFxPos0KJerfelcVg 59ZTRQN7UfBjM4ByArm0P9BceXi8SyAS5+Y1EYvWdUqW6teMU3gQCteyQi15/SKrWH3x HCNrqzfKjGyur9780A0j2eE0IkyWE3GlrEnkJ40e0bI2RK6oddRc2A3BuiA7QEA5PM4L MlkhqyV62Crjyi66C3yI+AjGupaBgA8Lf0lfe2BFobFuit1Rh9xhnCLP3/sMaDaovnlm X81w== Received: by 10.43.7.132 with SMTP id oo4mr16322745icb.6.1353479211102; Tue, 20 Nov 2012 22:26:51 -0800 (PST) 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 n20csp440295igt; Tue, 20 Nov 2012 22:26:50 -0800 (PST) Received: by 10.66.87.163 with SMTP id az3mr15038332pab.62.1353479210500; Tue, 20 Nov 2012 22:26:50 -0800 (PST) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by mx.google.com with ESMTPS id m8si21050901pav.104.2012.11.20.22.26.50 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Nov 2012 22:26:50 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.160.42; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.160.42 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-pb0-f42.google.com with SMTP id rp2so4281374pbb.15 for ; Tue, 20 Nov 2012 22:26:50 -0800 (PST) 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: ALoCoQlRFwrOyW4f86UJNQtr8roBo/fXe6r4HTBeaIyGbxF8UQM3UAETVY7+tT9w+FHpIMxYJ09Q 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) {