Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2135813imj; Sun, 10 Feb 2019 19:41:28 -0800 (PST) X-Google-Smtp-Source: AHgI3IbpvYkLwPSYYhWC2wPBf+rhYRhzZ9T9t9SvtQTFm4etRA1r3105rNGjsY0oixH7PitZ/pSG X-Received: by 2002:a63:3fc8:: with SMTP id m191mr4756236pga.240.1549856488184; Sun, 10 Feb 2019 19:41:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549856488; cv=none; d=google.com; s=arc-20160816; b=L0sH/kMy7gFYKKxzwZkT+LCxkslWnCX0NgjtBoIEgXpKV1EQFxVeDNO1zt8+GdC0bK YkXJWcNdMYW/EVm/hwTGdHKxGUrZnxjXcutLcFFuZ+EQVmRe7l51YNqjWTlc6AFmaLJq 4WMJ0zzBb6DMzmgNJaKDmCZOuT0tkcetIWdyaPmMxbHF5/vvrF73eLArR7XHj1XTApPL 7/jokqWzy4YJRxQLcLkQthSF2mJRjmu4R/enuyNJLIz8QkE5Ypx8rh9GeFPE/KXclTmi 1jcVKM8Z+bieBCQP2+XqizG9Nn9tRMymapMfh0A7EwGsKdWWyJKj91IykgEuUyfkNXTy j67Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=qWPDfOlXuramtow7KSV1zTmIzyR/XqoO0VQtrh+RpUI=; b=HUNLc6G6q7kBjh6oqp0i0xkpdiSgsvku6IEsW6TbJJnVUosxefJPlsvTQLvXEcmhHx dfL6r4yKaPPUOGwC5tzBvoSP9UJNsMTsJxJt6HkYkLwHVd8IqvC/ECIhZ0B0wA+UX7AY FhvO4KJKjU4b+5rgaDYOWKeBGF0gVEoZQQU3ICkcNRUPlTkZnRhkDF0HlkrkLHPQzWAg 6DlgZEaWdNph11y091XnhU8VSM3Pb+8v+QAlkdDOFO09I1wIg2j6QlYtrqZJfEozHvQY +r4lzZ80VtdSfi45ZxDkGgEErv7TrZGQE0Jbr6vgpyWkLHv9OI3Kw2gPGO3tSmzkXr0c cH7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OzmXhmms; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a11si10003005pla.20.2019.02.10.19.41.10; Sun, 10 Feb 2019 19:41:28 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=OzmXhmms; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726253AbfBKDlF (ORCPT + 99 others); Sun, 10 Feb 2019 22:41:05 -0500 Received: from mail-ot1-f73.google.com ([209.85.210.73]:56829 "EHLO mail-ot1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726102AbfBKDlE (ORCPT ); Sun, 10 Feb 2019 22:41:04 -0500 Received: by mail-ot1-f73.google.com with SMTP id q11so9733966otl.23 for ; Sun, 10 Feb 2019 19:41:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=qWPDfOlXuramtow7KSV1zTmIzyR/XqoO0VQtrh+RpUI=; b=OzmXhmms4G5PmaQpbOY3Wr5Ov+FXdEZCIxbI6mgH1uBU7JB39ElREirrztNifIEgb6 E8vj5BduBgp1yk2iOSl7mv1mHYKC1z6JNVLktsUMdoF7WmyBb69uExzwkOBP1LSwS3cv el6+2o4NmLEZ6x1OOOGkB4mTaq3PwuCzh6aDn20xyADlsGYc1FwW9ny+Ub7lIYltvuTK HDbCykvUy58IccJKrjmB7VxHZo8abr3wWAOwWSZT9XHCUMcOqzDOQmfc1+CvURH+XAQb Xv9arLUDpvKzEPKvBgJE2PEKCuDIUf5EttyC2OFKSO+VquqidoPzzn1H2i/aWlVNI8xX H00w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=qWPDfOlXuramtow7KSV1zTmIzyR/XqoO0VQtrh+RpUI=; b=plzF3CtmU4UBtKJpngRbJjK/gUoXo2B7E5D4X1gPppszIX/LQsVJf51VV6Q5g0dpP7 aFyF1P/gxVPwlPrWD9TwCCMxzY58ikzNoxsW7YMwk/8q7WxnIjbplpFgIU1I0XpZS804 tVdEz6Dc2FIVznQYy0rH3d+wUlGGx2/hTW4GNOanUCI5o9n2zxl7lzp74rvSiblnVoRJ CkTVOaa1ZDrYwrv/kxVxetzqaIyLiSPqcFGXrONUt2Ypxwhe1HA8xBLq0z2aSYNnXMbR RnRLxRvvWClwku4P9YLpKGBsncfQh8Ko5ZW4zY1P79sOT9J3U9B3+TNjXknbzSldRntz dMAg== X-Gm-Message-State: AHQUAuYsDHiGTrE6OrqTfuEVkcjifKKeDNSHLjVIj37YbEoYBKPCocoa AZAWjY7SC1syTy1OndM8Q9t225d9TcWFKE4= X-Received: by 2002:aca:5044:: with SMTP id e65mr2653040oib.11.1549856463576; Sun, 10 Feb 2019 19:41:03 -0800 (PST) Date: Sun, 10 Feb 2019 19:40:21 -0800 In-Reply-To: <20190205190849.GA2686@kunai> Message-Id: <20190211034021.242932-1-jsperbeck@google.com> Mime-Version: 1.0 References: <20190205190849.GA2686@kunai> X-Mailer: git-send-email 2.20.1.791.gb4d0f1c61a-goog Subject: [PATCH v2] i2c: core-smbus: don't trace smbus_reply data on errors From: John Sperbeck To: wsa@the-dreams.de Cc: jsperbeck@google.com, linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, rostedt@goodmis.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If an smbus transfer fails, there's no guarantee that the output buffer was written. So, avoid trying to show the output buffer when tracing after an error. This was 'mostly harmless', but would trip up kasan checking if left-over cruft in byte 0 is a large length, causing us to read from unwritten memory. Signed-off-by: John Sperbeck --- drivers/i2c/i2c-core-smbus.c | 2 +- include/trace/events/smbus.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c index 9cd66cabb84f..132119112596 100644 --- a/drivers/i2c/i2c-core-smbus.c +++ b/drivers/i2c/i2c-core-smbus.c @@ -585,7 +585,7 @@ s32 __i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr, trace: /* If enabled, the reply tracepoint is conditional on read_write. */ trace_smbus_reply(adapter, addr, flags, read_write, - command, protocol, data); + command, protocol, data, res); trace_smbus_result(adapter, addr, flags, read_write, command, protocol, res); diff --git a/include/trace/events/smbus.h b/include/trace/events/smbus.h index d2fb6e1d3e10..a4892a187842 100644 --- a/include/trace/events/smbus.h +++ b/include/trace/events/smbus.h @@ -138,9 +138,9 @@ TRACE_EVENT_CONDITION(smbus_reply, TP_PROTO(const struct i2c_adapter *adap, u16 addr, unsigned short flags, char read_write, u8 command, int protocol, - const union i2c_smbus_data *data), - TP_ARGS(adap, addr, flags, read_write, command, protocol, data), - TP_CONDITION(read_write == I2C_SMBUS_READ), + const union i2c_smbus_data *data, int res), + TP_ARGS(adap, addr, flags, read_write, command, protocol, data, res), + TP_CONDITION(res >= 0 && read_write == I2C_SMBUS_READ), TP_STRUCT__entry( __field(int, adapter_nr ) __field(__u16, addr ) -- 2.20.1.791.gb4d0f1c61a-goog