Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1597449ybv; Fri, 21 Feb 2020 00:01:10 -0800 (PST) X-Google-Smtp-Source: APXvYqzZc1cZqdOQZsLSl86G7j/BNIlOW+sZ+KhUAAodTzBOMnmU2Hg23u99SpjfvTBibpclnvSn X-Received: by 2002:aca:cf07:: with SMTP id f7mr955394oig.5.1582272070191; Fri, 21 Feb 2020 00:01:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582272070; cv=none; d=google.com; s=arc-20160816; b=U/oxKl7j4/6kFaSTYldOqb0RPu/l94vneRuvjv7gyKONs4oozHo6+WCRoTgPSFZh4A 6XxGQGBeHFoXbcMFEMRMEX5z/LU4lgpxaQ6MHipmkrTZ89dHEp1fSNzfSu3pvZxEoWjt cxI/+b3qWyLN8tb6+LGlWw2GyV+vfWZllRP+60fmw9kCRu12trfkEQQ+6pe0rxBue30F G4WaDnOZT+VsaiOeJ5MW29FEajMq+THl3X2o8ItjmHXY1+jgVynLOEHtjjzVEJxGdvwp 7ANNKeqvucUeJbGYn6254dExivkQwPRdY52eOPmg6vrjZn6gSpzJGZEZVdjld54UML+O rtww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m/8Z4X+F7Zx4hH9/tmsOylSydskC4o/q1sq6txLR1aY=; b=ax4Xd8PVSmmchEFpKL2k5X97pXsyStkwUiSFjxMKB03NpWatId+AWaIfY3l3qqcPRp TyKdPTCedzHodz3slnDdLpdqzRpIN54bKXr1SwEIGeDLdxmF42UZCyhkbbm+XT6oeyqb MWVUkXuUKa/IKBHiragOSfnVh1NwVOXg9oQjHPe58YlnLyhloJEKMjpku55wMtmQ3tPV qsxgVWzQVqvqY89FpAEXH84tB75bUfZ+/T6enXbO+yXWeE0xGxJxHOP93VXKqOZ9Nf7u MZlChnng69h6uKYI3NzV2V/jzQkAYaCpoAjCiGc6QnernMmPGoyqV2jsYgpGdiEuqS6s xm3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=GqgQVrmz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p25si1045924oto.191.2020.02.21.00.00.57; Fri, 21 Feb 2020 00:01:10 -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=@kernel.org header.s=default header.b=GqgQVrmz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730962AbgBUH7u (ORCPT + 99 others); Fri, 21 Feb 2020 02:59:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:59994 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730626AbgBUH7t (ORCPT ); Fri, 21 Feb 2020 02:59:49 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 73ED8222C4; Fri, 21 Feb 2020 07:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582271988; bh=zgVsgEnnXQ7LrYe7AE7KvemzilGGhK+OX2oKdOz0gEs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GqgQVrmz3eoARox4mz8EHj7VU/QqnhXEepWBykuZJKYjQsMl7b74SWpVNS2HKpwyX quqb39HeX1eztOnOzIoMWoUC/4Kd+UT4/8qOpVH9qYhjLpEMlDOZT901yQcGcddnzH +ZDuipg4VJUvVZXtFUwY/X1DFVUZxLkHBwBE6qRA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kbuild test robot , Coly Li , Jens Axboe , Sasha Levin Subject: [PATCH 5.5 374/399] bcache: explicity type cast in bset_bkey_last() Date: Fri, 21 Feb 2020 08:41:39 +0100 Message-Id: <20200221072436.745148874@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200221072402.315346745@linuxfoundation.org> References: <20200221072402.315346745@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Coly Li [ Upstream commit 7c02b0055f774ed9afb6e1c7724f33bf148ffdc0 ] In bset.h, macro bset_bkey_last() is defined as, bkey_idx((struct bkey *) (i)->d, (i)->keys) Parameter i can be variable type of data structure, the macro always works once the type of struct i has member 'd' and 'keys'. bset_bkey_last() is also used in macro csum_set() to calculate the checksum of a on-disk data structure. When csum_set() is used to calculate checksum of on-disk bcache super block, the parameter 'i' data type is struct cache_sb_disk. Inside struct cache_sb_disk (also in struct cache_sb) the member keys is __u16 type. But bkey_idx() expects unsigned int (a 32bit width), so there is problem when sending parameters via stack to call bkey_idx(). Sparse tool from Intel 0day kbuild system reports this incompatible problem. bkey_idx() is part of user space API, so the simplest fix is to cast the (i)->keys to unsigned int type in macro bset_bkey_last(). Reported-by: kbuild test robot Signed-off-by: Coly Li Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- drivers/md/bcache/bset.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/md/bcache/bset.h b/drivers/md/bcache/bset.h index c71365e7c1fac..a50dcfda656f5 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -397,7 +397,8 @@ void bch_btree_keys_stats(struct btree_keys *b, struct bset_stats *state); /* Bkey utility code */ -#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, (i)->keys) +#define bset_bkey_last(i) bkey_idx((struct bkey *) (i)->d, \ + (unsigned int)(i)->keys) static inline struct bkey *bset_bkey_idx(struct bset *i, unsigned int idx) { -- 2.20.1