Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1150416pxb; Wed, 6 Apr 2022 09:54:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJrcOOEpVd20Wip2P0yqkQCF1HY4+DpVLy8Py64HPmttbGMYUureg+ghKlEHPHU07Y8/Xg X-Received: by 2002:a17:90b:1805:b0:1c7:ba88:9550 with SMTP id lw5-20020a17090b180500b001c7ba889550mr11180460pjb.16.1649264066259; Wed, 06 Apr 2022 09:54:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649264066; cv=none; d=google.com; s=arc-20160816; b=idkPk+DFCRni6tc33MM71mOL+2BaOcLI4qJa26LYhl+tMf15RCzi/DuAl6rxUiCh9w k+ZcidLkok7pD24pnPrXeG3plBL0axLhrGGPSO/RkDPE9UgzRGQSxcwK+iEEnZy9HU4t /8TyhAhG3oPfup35NZ7XG2AmRKkgmkR5ZRwMmEUKJ8wwoyflWWjgG/XdLOFpl6K8yJ63 ZLWtM6sNAeGHJTIBlnNeJtpYdUsCdxAbfR1wumxdEzyobaKbx2CN3UR6HcuKjqbAMNe2 JOj2tpksK8SdVwO6poN46K55DNFQ3PbCbdiNFArY4OmucASMkA6BE6O01D9MsWJKkA82 xoQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=WdGgY7q/zKGZEnAEkIvkjjpuneUkqrHmpYaaNJPchfE=; b=HUzQ8yYy8lmMksRPMpTeqdJepJgcT3bTXGn3sHd/klV/2uHSXS5r3WQylKASD8EnNO yX1oCmNx2I+WEyDulUicfUJ9KaDDDVp+SJm95l7z7jL1NkFqGTcPmycDDXOrSMXggGm7 cfGM9Ldw3m8+U0I2vcxJdg+c/JknDpAhKOcRHWx2MhyszWXr7lPBZ/8IDxLiOuaq1exd ZV+JR0b3r6xY7hBwN8J8wsFWf9kddrSwlCOMaWA0yQZH/W4O/YdlVNLseUEwa7wDb2ks kMsrAZedo9sYNP00CXGBU58Yb6BIexcSjsaGXGQ8/5PA7ykENUAPEfAQ42aQHpTYmQcV 0NdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6vThwtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mq17-20020a17090b381100b001c6fb9a0ff6si6779674pjb.161.2022.04.06.09.54.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 09:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=J6vThwtF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 38CA83B9CCC; Wed, 6 Apr 2022 09:08:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237140AbiDFQJg (ORCPT + 99 others); Wed, 6 Apr 2022 12:09:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238367AbiDFQIl (ORCPT ); Wed, 6 Apr 2022 12:08:41 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48DB22B4A4B; Tue, 5 Apr 2022 21:17:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1649218623; x=1680754623; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=mqH7z+67UJ3aSBQZLGAzbRcUX3Z7J38wJRCxzX1Fenw=; b=J6vThwtFB7uovOqnw7Zf5NqGQJVcUDQQfAZ8pCyJKM4ZodYS9gUQJ3Ds 6r6pJVDdYmgYOXBHYdu2eyq5uITiTG5lE+dWHTPKf/TWuwzEd2yFIFn/m ONm9vdT1sgTggDXmuyR2KNgI/Ju4QXxkSrfhSRM096/zF1QsAsij6em6w LEkNPVuVVIabnNNtVnFT/77il7Fn2GZL7JdMpG+SfRXjqpjetgL9BI0yM Ul9c3R/SyZ9OC/wWjbc2i7XTmhpxS9CxlprD6kI7LFk9zR0c9pvzySVQ1 N6nFyY//rjvXkMbNq4R5ohO5pWPo5VYUuY+TLJG8p8UhWVEBqpj9FdvbF A==; X-IronPort-AV: E=McAfee;i="6200,9189,10308"; a="240879261" X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="240879261" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Apr 2022 21:17:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,239,1643702400"; d="scan'208";a="790198741" Received: from unknown (HELO localhost.localdomain) ([10.23.185.145]) by fmsmga006.fm.intel.com with ESMTP; 05 Apr 2022 21:17:01 -0700 Message-ID: Subject: Re: [PATCH 05/11] i2c: ismt: Fix undefined behavior due to shift overflowing the constant From: Seth Heasley To: Borislav Petkov , LKML Cc: Neil Horman , Wolfram Sang , linux-i2c@vger.kernel.org, seth.heasley@intel.com Date: Tue, 05 Apr 2022 14:18:21 -0700 In-Reply-To: <20220405151517.29753-6-bp@alien8.de> References: <20220405151517.29753-1-bp@alien8.de> <20220405151517.29753-6-bp@alien8.de> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5 (3.28.5-8.el7) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2022-04-05 at 17:15 +0200, Borislav Petkov wrote: > From: Borislav Petkov > > Fix: > > drivers/i2c/busses/i2c-ismt.c: In function ‘ismt_hw_init’: > drivers/i2c/busses/i2c-ismt.c:770:2: error: case label does not > reduce to an integer constant > case ISMT_SPGT_SPD_400K: > ^~~~ > drivers/i2c/busses/i2c-ismt.c:773:2: error: case label does not > reduce to an integer constant > case ISMT_SPGT_SPD_1M: > ^~~~ > > See https://lore.kernel.org/r/YkwQ6%2BtIH8GQpuct@zn.tnic for the gory > details as to why it triggers with older gccs only. > > Signed-off-by: Borislav Petkov Reviewed-by: Seth Heasley > Cc: Seth Heasley > Cc: Neil Horman > Cc: Wolfram Sang > Cc: linux-i2c@vger.kernel.org > --- > drivers/i2c/busses/i2c-ismt.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/i2c/busses/i2c-ismt.c b/drivers/i2c/busses/i2c- > ismt.c > index f4820fd3dc13..c0364314877e 100644 > --- a/drivers/i2c/busses/i2c-ismt.c > +++ b/drivers/i2c/busses/i2c-ismt.c > @@ -145,8 +145,8 @@ > #define ISMT_SPGT_SPD_MASK 0xc0000000 /* SMBus Speed mask > */ > #define ISMT_SPGT_SPD_80K 0x00 /* 80 kHz */ > #define ISMT_SPGT_SPD_100K (0x1 << 30) /* 100 kHz */ > -#define ISMT_SPGT_SPD_400K (0x2 << 30) /* 400 kHz */ > -#define ISMT_SPGT_SPD_1M (0x3 << 30) /* 1 MHz */ > +#define ISMT_SPGT_SPD_400K (0x2U << 30) /* 400 kHz */ > +#define ISMT_SPGT_SPD_1M (0x3U << 30) /* 1 MHz */ > > > /* MSI Control Register (MSICTL) bit definitions */