Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp1137905ybf; Thu, 27 Feb 2020 05:45:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxQa2xAHLC0vvkh3wAVkN4LtO5UahJAE2E7dmSBJlvsQ/fa4ty/RE5sIQ75Jce8zFsHuZgS X-Received: by 2002:aca:889:: with SMTP id 131mr3177605oii.3.1582811108827; Thu, 27 Feb 2020 05:45:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582811108; cv=none; d=google.com; s=arc-20160816; b=aEARx9B8+9GTgn1NAjDKsi4evzpAx270JmgfXbjTSd+TPOFV/IxwS4HBpvubffgMy6 M1YX2KoGgzN1nCEhnWup9hqgts+JXR9kQlIyzVPb5zAipBxr2CswRg0K9AUMmwk3wk6I zw9yZrP6KdqoCjyn3pPUXUSRLvuKUmyT1G2uvGwZ45tt1ze70TzGrbgam2VH9ED1HXu3 HIis7NQFIWJWa72kufxDyU93yWLXutk3GBWD4dzisTeh/6Py2j/qZtAuzoZ3OkrEISw4 qIvXh3i3XoumwSXLbELIAmlt9eqALhdxNAY2aklY3VCPilPDSf1CfLcgjldx4e8aW1w7 hKYg== 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=Fy4GTaRPmL6NvJPpnH2owGDEzITP+x3+CDohfAHA7m4=; b=cBTOBzgZtX/JcHeJ1jSMu4qSBYKHHELKv9KJJ6xFtglwwX/BAlbHSsd1Ksvvkx+7eQ qZB6NhJcdj8VGRHxc78h0GrEqso4+sAXgkzLaCAYZiAUZ8fqeXPRVr0Ufo4Oer+YRFC1 vrHGi4+32CiRXDF+uM76iffSlLpa2QrZ2Uub7HjQPu/bOljNlaC8y7Prs0R2UxivLU1k 5t1epuszpOrQLBosype5TsGfAu/eTT+aw1vCtuuCyLWhj0+yeF74YkJikE9beCyA2bp3 6n32LlCyxDgzpMwowmkVfsCBkWL6KZPXjX1xBTpaYsBfpah4XqKUcIgTmeWUiedALLxo cvXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LwADJTBw; 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 i15si1601083otk.120.2020.02.27.05.44.57; Thu, 27 Feb 2020 05:45:08 -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=LwADJTBw; 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 S1729639AbgB0Nn1 (ORCPT + 99 others); Thu, 27 Feb 2020 08:43:27 -0500 Received: from mail.kernel.org ([198.145.29.99]:38602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729953AbgB0NnY (ORCPT ); Thu, 27 Feb 2020 08:43:24 -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 3709C24656; Thu, 27 Feb 2020 13:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582811003; bh=RQoQ8frxlbI1QjilHnH3/LmzPQ60HcJMzxc+C18UY60=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LwADJTBwWPj20caqaJqKTEDLKMIUWFdgMR/zOMMVW76DPmXNpf5ETBkIlE2i3fA1D pmk7WMN+xW48Q35a5fvNmom1zp11UrSMixvf4N6iwUiXgtHROa5ifLBSAcgvdui7IV 2J0s3QDnyFxnbw8Fe0X/U48UgmwfHBGzjqY/0//Q= 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 4.4 079/113] bcache: explicity type cast in bset_bkey_last() Date: Thu, 27 Feb 2020 14:36:35 +0100 Message-Id: <20200227132224.426128561@linuxfoundation.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227132211.791484803@linuxfoundation.org> References: <20200227132211.791484803@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 b935839ab79c6..f483041eed986 100644 --- a/drivers/md/bcache/bset.h +++ b/drivers/md/bcache/bset.h @@ -380,7 +380,8 @@ void bch_btree_keys_stats(struct btree_keys *, struct bset_stats *); /* 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 idx) { -- 2.20.1