From patchwork Tue Aug 15 20:39:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 135741 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a888:0:b0:3f2:4152:657d with SMTP id x8csp1014015vqo; Wed, 16 Aug 2023 03:40:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+yFSIGus6XwiNbWnzJkIa9IZeNo3fRGeRt2aO3L2HrShk19336F06HF7EgC2aFZS1QUPF X-Received: by 2002:a17:907:6d92:b0:992:103c:43fa with SMTP id sb18-20020a1709076d9200b00992103c43famr5243176ejc.30.1692182433391; Wed, 16 Aug 2023 03:40:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692182433; cv=none; d=google.com; s=arc-20160816; b=gr7dSidEnAlHDRL1g6cxbb9tWaHTByisNek/QTiAbud92oGPAh/6oh9G+fgLu5Lx7g V8LD0Oj2edqrtPU/4Lyi6D2h94dA0GEyGLQwWzWIoS7yuGBsXce4gfL8v+f21FXOO2yq zsgsmz+j/AsVh7O+9TDb1glg2rouYqF4QNMRnfSdPNUpJIZgwj/f8nwYjjXGjmmlS8Gi uUfgsxR7O5pqpcsgtnEmj9heaZmGxKnVZlnt+dwNyLW4nJN1xToeJL6NI2F4/mAENuW2 u5WNBv3YRdd0Bf4QxfqM8Cc0UKM/AwSBsDeUsSigyZsU//kccH1xSXHK/2bGnUX2I1IY FDgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=kvHdzx1NIsej7bMHDGVdstKC+O66PqWf4mjIbBcFk1w=; fh=ahAu6VpQ08G+pqAHmzGBl0oAjDD66WAOUL7vh9fGIEU=; b=s9oVocsKNd7VMmWlWci+MNyECCKrb0hf68mGWGpJAmVf3MA3ZVflWHssjtVPajmUhJ GvnlOJRraqB/2JHuEqHe0aM5MwSOmBMeYbF0RcgSYzIucA7IaLxG93xef6I9+/iotvJo MKL8tEvk5a8daF2j7aNgHUUb/vNZtDTTQru5QsXPDsUgMZGkHukBc7bz4lif5Remqd5M p0fCbw+HDJHrvEnGSm0dpA07gyB6QzIc8xnPjeWFv7CmDbC/l0bOzD4FA2lDLnTZrsjH xPfrF4uEKGG0VkbXd3AaAf9IHxBSWIpj33WaKlrBQ+qy+z2xvHCW5cbWy8XbZCjwl1AW N1kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nBc+VsxS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i8-20020a170906a28800b0099325282809si10480782ejz.572.2023.08.16.03.40.09; Wed, 16 Aug 2023 03:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nBc+VsxS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238000AbjHOUlA (ORCPT + 99 others); Tue, 15 Aug 2023 16:41:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239356AbjHOUkm (ORCPT ); Tue, 15 Aug 2023 16:40:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4BDD92680; Tue, 15 Aug 2023 13:40:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BD43D66198; Tue, 15 Aug 2023 20:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68349C433C7; Tue, 15 Aug 2023 20:38:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692131932; bh=nzA4p2In00F8WGqv2J+xq1zlDnCIJQPQMghB0lPPiwE=; h=Date:From:To:Cc:Subject:From; b=nBc+VsxSWlJRhY8XMqEEgzmxYDWgeyO34ygkLKmUG1f7tUvuLqVGWelqX58v3K09r nzPvQBKE4q07GRweF62bfu9+ma80XtDw1Ti6hiJT82GXGqGCi+WCLZqsJ8ZcMqGnaI Gan5J9n8JxAkbPlP8TzL+NHVk/BFrqcGcAeBZvtFpE+9JsXh5uJgpycldKKbE5gwzl 0wXKHGLJAkuXJ0QMWBpKZcUltd9NdEctehvDfVCgYZgo1tr9/1AzgwQ6GpkcePjhMk 1x9NTYWIiXnOKzhNMbVzp0VzLpDURGSC3VVxJrrzMweSVo+R2XHNYXANBaNLoVONCe nTsxhpPeLztrQ== Date: Tue, 15 Aug 2023 14:39:53 -0600 From: "Gustavo A. R. Silva" To: Yishai Hadas , Jason Gunthorpe , Leon Romanovsky Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] RDMA/mlx4: Copy union directly Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774375118139225529 X-GMAIL-MSGID: 1774381887518894957 Copy union directly instead of using memcpy(). Note that in this case, a direct assignment is more readable and consistent with the subsequent assignments. This addresses the following -Wstringop-overflow warning seen in s390 with defconfig: drivers/infiniband/hw/mlx4/main.c:296:33: warning: writing 16 bytes into a region of size 0 [-Wstringop-overflow=] 296 | memcpy(&port_gid_table->gids[free].gid, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 297 | &attr->gid, sizeof(attr->gid)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This helps with the ongoing efforts to globally enable -Wstringop-overflow. Link: https://github.com/KSPP/linux/issues/308 Signed-off-by: Gustavo A. R. Silva --- drivers/infiniband/hw/mlx4/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index 216aacd72e4f..2d2cd17e02e6 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c @@ -293,8 +293,7 @@ static int mlx4_ib_add_gid(const struct ib_gid_attr *attr, void **context) ret = -ENOMEM; } else { *context = port_gid_table->gids[free].ctx; - memcpy(&port_gid_table->gids[free].gid, - &attr->gid, sizeof(attr->gid)); + port_gid_table->gids[free].gid = attr->gid; port_gid_table->gids[free].gid_type = attr->gid_type; port_gid_table->gids[free].vlan_id = vlan_id; port_gid_table->gids[free].ctx->real_index = free;