From patchwork Tue Dec 24 11:42:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 3402041 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 CC49A9F375 for ; Tue, 24 Dec 2013 11:45:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D090E205F9 for ; Tue, 24 Dec 2013 11:45:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0366E205BA for ; Tue, 24 Dec 2013 11:45:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752056Ab3LXLpo (ORCPT ); Tue, 24 Dec 2013 06:45:44 -0500 Received: from mail-pb0-f42.google.com ([209.85.160.42]:57882 "EHLO mail-pb0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751974Ab3LXLpf (ORCPT ); Tue, 24 Dec 2013 06:45:35 -0500 Received: by mail-pb0-f42.google.com with SMTP id uo5so6415607pbc.15 for ; Tue, 24 Dec 2013 03:45:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u0qCQGrhuS0qWyHQ32Cc8L54XFInULuxiT/5qmtBQ8I=; b=GNvX3Q1IKvHRBkiGtpgjTC3NU2T1fxU8YQXB/5TegF+lWKVoP5+IE6ZxV88ItPj3pS rk2OKG+rjRyO+t4bvrGU09BQYbi9cTiLUQMhgfWBnK0zaQby9HDCeMDiJi9n8swdWPoj 2ZYJz5B94rNXUVNbarQtELuNsXAZF1uDt14cAKPQwMWfhcNGUE2AcupvKHlZsIV/kZMm iQD7lvTCfxtIitgX7emAMpXkK3zpynDng9eH3bFNtb4GieUB5UMT7TzrF+johgWyiRk+ Ox/HGk1NPSlMIUr08HrVuBb0oeyhbHYfADeyhs7g/P5p8vAdBMX+M5XaLYxXtHw/PogG yKxQ== X-Gm-Message-State: ALoCoQl6PZsRHmnrG1vif4nAhRRInjftGtJGD0MI4s75C9s5rsT15PiVMrMyp4HNqRksHU5D0UPP X-Received: by 10.68.211.39 with SMTP id mz7mr31846141pbc.90.1387885534567; Tue, 24 Dec 2013 03:45:34 -0800 (PST) Received: from linaro.sisodomain.com ([115.113.119.130]) by mx.google.com with ESMTPSA id ug2sm53640678pac.21.2013.12.24.03.45.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 24 Dec 2013 03:45:34 -0800 (PST) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: a.hajda@samsung.com, s.nawrocki@samsung.com, sachin.kamat@linaro.org Subject: [PATCH 3/3] [media] s5k5baf: Fix potential NULL pointer dereferencing Date: Tue, 24 Dec 2013 17:12:05 +0530 Message-Id: <1387885325-17639-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1387885325-17639-1-git-send-email-sachin.kamat@linaro.org> References: <1387885325-17639-1-git-send-email-sachin.kamat@linaro.org> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.4 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 Dereference 'fw' after the NULL check. Signed-off-by: Sachin Kamat --- drivers/media/i2c/s5k5baf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index 974b865c2ee1..4b8381111cbd 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -548,12 +548,14 @@ static void s5k5baf_synchronize(struct s5k5baf *state, int timeout, u16 addr) static u16 *s5k5baf_fw_get_seq(struct s5k5baf *state, u16 seq_id) { struct s5k5baf_fw *fw = state->fw; - u16 *data = fw->data + 2 * fw->count; + u16 *data; int i; if (fw == NULL) return NULL; + data = fw->data + 2 * fw->count; + for (i = 0; i < fw->count; ++i) { if (fw->seq[i].id == seq_id) return data + fw->seq[i].offset;