Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp4813506imj; Wed, 13 Feb 2019 01:18:59 -0800 (PST) X-Google-Smtp-Source: AHgI3IYrkn5Ai6QdIWEvVX0HnxiV3/TL3a1GOIy86SYyPMBcGjR+W5EHiIgrEYa7BueVdFXBh2GU X-Received: by 2002:a63:100c:: with SMTP id f12mr8070368pgl.324.1550049539597; Wed, 13 Feb 2019 01:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550049539; cv=none; d=google.com; s=arc-20160816; b=ye7SvuMX7ylnQBM0VV+q2/oRu4nAMvVgfMZLhkuUvOFpeMXviHErOTZYEfIcBTvkq+ yo3hChWCyLz/QEDCD9a67ETOLhJJTwAoORaztGgYbxD95BkZx1w5/vUdodZ93iWXMXg/ yg28c3TBkfpTQiTwOSm5tj9GbKtNh1epYyDb4U7mGm/oDvIwKixIukX2kxe6O+ctBG2z YJkYa6yT8hxkIdndBPbMYOl/+UJclDhoPz07zN0lOsCUPZgGcTSotg0RZngCvDW3U7JD CMK8lkSXG7nGzxnfzx/GPm+Ghel/zBfNPgfr9RGzYFii1EXota1CJj/8Qi8FMRGnhm+R m7MQ== 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:mime-version :message-id:date:dkim-signature; bh=H8VWqK0/t0TuXLPVjLMEmQZc5d0Pj3Z1HvvTA0WvRH8=; b=ZJDZyw/RkPEWonEuvi4zh50woYbEmuTQxelhHu+g/5DCV1ICf75bDQRKfHyNoZPNWP Z4vDxvJWlNw+/lZtngw+OY7elhda8S3Hp3vsHIfJFazzHd7MJ/KtxvsWHeQNiaRt/GB6 CK6Q/ZVAklpPs/pO02PJ5RPn7UGGrdTc+5STlUOJ2kwfnOz49VHoZNdQVs9ccJ2Lr/Wo Ts55+aXsIfGnSD4IefKpNVe5zKsbFA2Q1IVwm1DscOmb+/zRkVMfJptvvPgkKEl2jjwJ RtBsJ3N6yowzjeioXpTaG8xwuQWCtaVgV5B/cplAu1ThBX2uxQd6CNOVzq8MAUdsuJ56 D8fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=J0c2zK1K; 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 c12si15243389pls.227.2019.02.13.01.18.43; Wed, 13 Feb 2019 01:18:59 -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=J0c2zK1K; 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 S1731575AbfBMDlE (ORCPT + 99 others); Tue, 12 Feb 2019 22:41:04 -0500 Received: from mail-yw1-f73.google.com ([209.85.161.73]:46887 "EHLO mail-yw1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfBMDlE (ORCPT ); Tue, 12 Feb 2019 22:41:04 -0500 Received: by mail-yw1-f73.google.com with SMTP id 201so657334ywp.13 for ; Tue, 12 Feb 2019 19:41:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:message-id:mime-version:subject:from:to:cc; bh=H8VWqK0/t0TuXLPVjLMEmQZc5d0Pj3Z1HvvTA0WvRH8=; b=J0c2zK1KOY19FQXT4b0LZAJm00/7ijjGmwCkz2XGYq/y6EeAcs1bwnGiFTWT88SpvD 4Rkk2f472ZvM3c3Xpp6UBVyM9Jg6T0YxDcxe/1kxG77woMwK7nnebvnfNjInRdT2TCwQ N8azKrx6lv92UB/S3vN+BRgiyaRrdoNYTVyj43ogHTKZjx0gFgrGKWDDzWLvP0GXwtfc 2G7ZBl82sA8X2Wo2XUCVcfLNWQdyjU0so290Kjc/SaxWhuLag4T5FO+anXzDQYHvbP9/ 3nNi1s3XFd86cx9a9yLzNyp1Oli9xRAss8xTXTHwbpW18LeCC3i/5vOonhxSRKZ+pbxM bRvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=H8VWqK0/t0TuXLPVjLMEmQZc5d0Pj3Z1HvvTA0WvRH8=; b=TSMyTSgM0AVlSDpD/gmaxdLgx1gdfg6oIoPGWo7p2a6HEJfCDKSzOccEAHQorQJ3u2 932Sl+y0UgkpDNgKxUJ/0SiofnaZkmk8Lc88oL0MvietrQ0Su4DPYcmT67zdpJ8tAQ1f 5JL8TDUG/CU7avgIkWGmuLGF78yXI+g6OjgwQrA0dKdITpmPpf4/UUl+6llxonN6Ut4m Jz8wJUz+IaVwC8E7xzXRdaoEkAHRPr8iTDpHfDFFlYpz+gPoCr97oqkSuKxFuQjx/Nzs SgQvFXmN6Z9nmgmB1nqd/GilsD6PzjFp3QP/AlzhCnMnYWIRMnEHkdKq+Tz7NLsIMs0+ TCig== X-Gm-Message-State: AHQUAuYOHp/eepkHtJvzDYOjQh7r7lD9IWNfzdqTnhh+hT70fs1kmypy So5XI9Z6jdvy7u4I8NJzAbl/DDICvEd2HbM= X-Received: by 2002:a25:b985:: with SMTP id r5mr3469352ybg.100.1550029263268; Tue, 12 Feb 2019 19:41:03 -0800 (PST) Date: Tue, 12 Feb 2019 19:40:57 -0800 Message-Id: <20190213034057.244716-1-jsperbeck@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.21.0.rc0.258.g878e2cd30e-goog Subject: [PATCH v3] 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.21.0.rc0.258.g878e2cd30e-goog