Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp95677rdh; Sat, 23 Sep 2023 03:04:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFMObte/7H+MrdJ30ne3gLxYtNhwKHXWfzvvvNuFOFURVsaCojFOSvB3mfYv8bSVuKkoUI3 X-Received: by 2002:a05:6870:5623:b0:1d5:a377:f360 with SMTP id m35-20020a056870562300b001d5a377f360mr2114720oao.41.1695463486973; Sat, 23 Sep 2023 03:04:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695463486; cv=none; d=google.com; s=arc-20160816; b=yVMVGHLCxaXj8Gp+vtp724bKNYq4+XByCt8sKpcM557BOchcQ5yHgou9t9TXH1e2na RHjwwIFoWjsdL9tpoN8cKn9jyrWZ4Z2i4Ti1jW6ypjj8/rpQjOgMX9hY3OqXxY8nlTHR U7UDguA9BpUNzNnKhUBhQIHZSwLo+9HAhTx77BVqVZUy2LBhQVHU841qlVzU5euKJSZR SZiIc/gqsPQlqX2OYbvzP899IRN4xKqow61Tnt5vYAiPBqxrBiz2Gl8Ah2n/Rsv51O2Q YW/0r/lWXhXxgYL70JrYKqYCNgXWCB3e6KI27txbZgbcyc07L5+MbCpc+9xZk7ruLtZb xO9g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=G7tAIoMWyx5SK/7lnnnDHZQxV+76Lbl3kc2YAXhhFds=; fh=2yufRnxVgDB6E00E0CYoMk9ra1uIpQAW/eEdwwY1QIU=; b=LeAZ99EbRMI9spOTHjjUO63XVoU3gYGh+x1vt2Dl9ARsRiTOjg0Lx8y7QDLbKLYMCb 1Bl1+BVOLhRR+kdI++Vw2xC8EQzibWIsgoRhogDpnB9O1Uf19BHHRcaMoS4Dn0xATUJn QSKefx62SZ5ZrbeBMtwddQjgsMeBw1KEwCfpnVkTaOQNL08lvDge8zZI5k6Pg9rBnH72 M93bdFMds3KbTqgEa1dO/YBfLZxiYH5WTUpUx/Cddn0kxmeA5JoYLZYPMZEH+j7fwNw4 GxcOyC4Gidsj5QuX66YpJjbRRKX7puQ16f3KYgtWEOJYcPLbX2QLSBwT3p+ZddKrQOql BNYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=MGzImVvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id bz41-20020a056a02062900b00578cbee11easi6510870pgb.9.2023.09.23.03.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 23 Sep 2023 03:04:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=MGzImVvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 5DC78819ADBC; Fri, 22 Sep 2023 23:16:02 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbjIWGPf (ORCPT + 99 others); Sat, 23 Sep 2023 02:15:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjIWGPf (ORCPT ); Sat, 23 Sep 2023 02:15:35 -0400 Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8DC119E for ; Fri, 22 Sep 2023 23:15:28 -0700 (PDT) Received: from pop-os.home ([86.243.2.178]) by smtp.orange.fr with ESMTPA id jvvKqieqFqQHijvvKqqbog; Sat, 23 Sep 2023 08:15:27 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1695449727; bh=G7tAIoMWyx5SK/7lnnnDHZQxV+76Lbl3kc2YAXhhFds=; h=From:To:Cc:Subject:Date; b=MGzImVvYYc5cHEX3tVkaysSdw4wuTrxD6R7sWHjIOZ2qws4JYxELVTHhdQ4eNkF+Y FSRNHfwED57IwVmOLTRF9Jfe4ckoQ5aYFsB8IOx6mhkvSeTpNkEL0Qk9NpdkInRH4k xL920sfyYWK6wUVTAY1hCvKm+Lx2oND0wzQM9br3tNBn0l8hmSb9WbbmPThSL6NBI8 6QWE3aRnarN3FP4mEBH+G6AgJZ9k6rzZGNRX3qjNowyYmX8ZyEVtqJ01UyQ/xHjVo4 S/UKjvIG4UCmOcp47MV3BK29U2pJvgV7P/rhm7tFO2jlJXDvNDRHdb+9oHdNdr6Hid ntKvus+7XzSxQ== X-ME-Helo: pop-os.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 23 Sep 2023 08:15:27 +0200 X-ME-IP: 86.243.2.178 From: Christophe JAILLET To: Jason Gunthorpe , Leon Romanovsky , Matan Barak , Doug Ledford Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET , linux-rdma@vger.kernel.org Subject: [PATCH] RDMA/cma: Fix the size of a buffer in add_port_entries() Date: Sat, 23 Sep 2023 08:15:25 +0200 Message-Id: <91395b73a64c13dfe45c3fd3b088b216ba0c9332.1695449697.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=2.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 22 Sep 2023 23:16:02 -0700 (PDT) X-Spam-Level: ** In order to be sure that 'buff' is never truncated, its size should be 11, not 10. When building with W=1, this fixes the following warnings: drivers/infiniband/core/cma_configfs.c: In function ‘make_cma_ports’: drivers/infiniband/core/cma_configfs.c:223:57: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] 223 | snprintf(port_str, sizeof(port_str), "%u", i + 1); | ^ drivers/infiniband/core/cma_configfs.c:223:17: note: ‘snprintf’ output between 2 and 11 bytes into a destination of size 10 223 | snprintf(port_str, sizeof(port_str), "%u", i + 1); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Fixes: 045959db65c67 ("IB/cma: Add configfs for rdma_cm") Signed-off-by: Christophe JAILLET --- drivers/infiniband/core/cma_configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma_configfs.c b/drivers/infiniband/core/cma_configfs.c index 7b68b3ea979f..f2fb2d8a6597 100644 --- a/drivers/infiniband/core/cma_configfs.c +++ b/drivers/infiniband/core/cma_configfs.c @@ -217,7 +217,7 @@ static int make_cma_ports(struct cma_dev_group *cma_dev_group, return -ENOMEM; for (i = 0; i < ports_num; i++) { - char port_str[10]; + char port_str[11]; ports[i].port_num = i + 1; snprintf(port_str, sizeof(port_str), "%u", i + 1); -- 2.34.1