From patchwork Sat Jul 29 01:00:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brendan Higgins X-Patchwork-Id: 795157 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="YTY30p9t"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xK6p235sSz9s0g for ; Sat, 29 Jul 2017 11:00:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753013AbdG2BAY (ORCPT ); Fri, 28 Jul 2017 21:00:24 -0400 Received: from mail-pg0-f47.google.com ([74.125.83.47]:37316 "EHLO mail-pg0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752848AbdG2BAY (ORCPT ); Fri, 28 Jul 2017 21:00:24 -0400 Received: by mail-pg0-f47.google.com with SMTP id y129so116894530pgy.4 for ; Fri, 28 Jul 2017 18:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=neuYIs0x3YrOmCWjJ40ujFNTeMcMywch5prqiDbC8bU=; b=YTY30p9thHlwgb09h2PAkyvUe+QSsOI2EscQBtyZFSLjVCG7lPgEUOhfHr4fPipjKd axdcilUwwEMS9/Zn7nLlqkKrVdXir86LCNhRkLQnzt+NPO2hNoo+CIwN7Zlfwo4Boh/I wm060YlAW2iiZe2vY1SLYw7cdqauIRnLSpmN+xU/o2AweMv+XdWdza3WP5V3Spk8Yv6Y TXZAJvK/O0q98+bkW5Sk/yueXTf4fn8DBOG4WVhLjKtlphW0dQRO9LY2JrVcAJsBryTr PT91N0AaHtzchiHi5s4R1Mq7TxOiHnJYpGgA/p4fVfkWwj+XADjoEddDpZNYW5blqCdy 24Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=neuYIs0x3YrOmCWjJ40ujFNTeMcMywch5prqiDbC8bU=; b=C9bKbTLhrE0gfLyznhBUAUDH0epzhftA4oI+fvXVrS8ZRxt1HhjXaDD6nPlZXruMAS QWmpgXHRSghHcxzOJtfgZNayF+Q1dgotF22wNTkX5RiZsTgOLJPxP71A9Awh/gD7CBVm v3nEPYL6bLsqQBkErbVjnlcKgkuBbNfqpd1rgjfNMPB6g2DreFX15z1mE+LSh6g5V1qQ ZJWzZE1e2mT1A68mkHxojxZDOh1gOvlxAo92uX4p7oowPgxoG+qqzpH+5pYQNmv6DjEo gW7jAj3Yk+ie//eWmbFQoxtg0R9+aWspO7cMDkN992T3thIKAgR12w1FNe+4Lg+Vvzsz 5x5Q== X-Gm-Message-State: AIVw113WgVZI+Y4INenSn2GA3VXVqxR6rifG+hjYgIagIXZlxlrPLc7N wOQcTXS1QISccubk7v8kEQ== X-Received: by 10.99.126.86 with SMTP id o22mr8904722pgn.385.1501290023493; Fri, 28 Jul 2017 18:00:23 -0700 (PDT) Received: from mactruck.svl.corp.google.com ([100.123.242.94]) by smtp.gmail.com with ESMTPSA id r64sm44830232pfj.62.2017.07.28.18.00.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 28 Jul 2017 18:00:22 -0700 (PDT) From: Brendan Higgins To: wsa@the-dreams.de, benh@kernel.crashing.org, joel@jms.id.au, venture@google.com Cc: linux-i2c@vger.kernel.org, openbmc@lists.ozlabs.org, linux-kernel@vger.kernel.org, Brendan Higgins Subject: [PATCH v1] i2c: aspeed: fixed potential null pointer dereference Date: Fri, 28 Jul 2017 18:00:12 -0700 Message-Id: <20170729010012.5032-1-brendanhiggins@google.com> X-Mailer: git-send-email 2.14.0.rc0.400.g1c36432dff-goog Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Before I skipped null checks when the master is in the STOP state; this fixes that. Signed-off-by: Brendan Higgins Acked-by: Joel Stanley --- drivers/i2c/busses/i2c-aspeed.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/i2c/busses/i2c-aspeed.c b/drivers/i2c/busses/i2c-aspeed.c index f19348328a71..6fdf9231c23c 100644 --- a/drivers/i2c/busses/i2c-aspeed.c +++ b/drivers/i2c/busses/i2c-aspeed.c @@ -410,10 +410,11 @@ static bool aspeed_i2c_master_irq(struct aspeed_i2c_bus *bus) } /* We are in an invalid state; reset bus to a known state. */ - if (!bus->msgs && bus->master_state != ASPEED_I2C_MASTER_STOP) { + if (!bus->msgs) { dev_err(bus->dev, "bus in unknown state"); bus->cmd_err = -EIO; - aspeed_i2c_do_stop(bus); + if (bus->master_state != ASPEED_I2C_MASTER_STOP) + aspeed_i2c_do_stop(bus); goto out_no_complete; } msg = &bus->msgs[bus->msgs_index];