From patchwork Tue Oct 27 13:49:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 311790 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECB88C55178 for ; Tue, 27 Oct 2020 18:13:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9D15A207BB for ; Tue, 27 Oct 2020 18:13:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603822418; bh=gDvY7EcElQuD5rxYTGAzgrnYsOghs9yk0ptOGQ5v1BM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Q2CRmdUKln5IPAGAZy9BdEINiZmjDECofqL3TAxXeGij1hCFuyWRKG79I8gZhv+S+ 4xiGwS3Kxm3R4ILR6JnKRg4nWzvnWi4rP+8aBKK/AUTkhgVnGsZNORQjIaEPuRl8eW Mz/enTpJtXLoNYGGig/jbxCG2xSCfhjRYq4VoTzA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754825AbgJ0OOI (ORCPT ); Tue, 27 Oct 2020 10:14:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:35620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2507943AbgJ0OOH (ORCPT ); Tue, 27 Oct 2020 10:14:07 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 BEC432076A; Tue, 27 Oct 2020 14:14:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603808046; bh=gDvY7EcElQuD5rxYTGAzgrnYsOghs9yk0ptOGQ5v1BM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=soO6E74X/TV6X9kmuc7oCVb2fbFqsy5tDGdCiRHKGpppCM1KJfsSLdGX6ROfMhrwq rKlFORaiAH+MQGKrG1BhKDWIWhGel1Kq0BzunFTtC8qg+FhGPBNcddRD01HpW3kUum 7ms00RVfbjHr2HSUK/XZpQQs1KrBpwy/Iwk9n9os= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Ira Weiny , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.14 105/191] IB/rdmavt: Fix sizeof mismatch Date: Tue, 27 Oct 2020 14:49:20 +0100 Message-Id: <20201027134914.745642930@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134909.701581493@linuxfoundation.org> References: <20201027134909.701581493@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Colin Ian King [ Upstream commit 8e71f694e0c819db39af2336f16eb9689f1ae53f ] An incorrect sizeof is being used, struct rvt_ibport ** is not correct, it should be struct rvt_ibport *. Note that since ** is the same size as * this is not causing any issues. Improve this fix by using sizeof(*rdi->ports) as this allows us to not even reference the type of the pointer. Also remove line breaks as the entire statement can fit on one line. Link: https://lore.kernel.org/r/20201008095204.82683-1-colin.king@canonical.com Addresses-Coverity: ("Sizeof not portable (SIZEOF_MISMATCH)") Fixes: ff6acd69518e ("IB/rdmavt: Add device structure allocation") Signed-off-by: Colin Ian King Reviewed-by: Ira Weiny Acked-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rdmavt/vt.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c index 64bdd442078a1..03a367db38e6d 100644 --- a/drivers/infiniband/sw/rdmavt/vt.c +++ b/drivers/infiniband/sw/rdmavt/vt.c @@ -97,9 +97,7 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports) if (!rdi) return rdi; - rdi->ports = kcalloc(nports, - sizeof(struct rvt_ibport **), - GFP_KERNEL); + rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL); if (!rdi->ports) ib_dealloc_device(&rdi->ibdev);