Received: by 2002:a05:7412:b130:b0:e2:908c:2ebd with SMTP id az48csp1707779rdb; Sun, 19 Nov 2023 07:12:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IG61vf/wsolvsQvCF/wTscGrCKqqxNkBc4xmM5zNqWL87KYI71bZzunlweczj0Gt2R03GSY X-Received: by 2002:a05:6a20:a421:b0:18a:be:9cda with SMTP id z33-20020a056a20a42100b0018a00be9cdamr1289442pzk.10.1700406763198; Sun, 19 Nov 2023 07:12:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700406763; cv=none; d=google.com; s=arc-20160816; b=zqo5ne+i+XyLF6+mdlLmnz3rbFX6yV5xWhycEchRriIIY1dYz/O1/lx26AbM05uqN9 TI352x8lYqRZmKHe4N3rWrBHn++LVN2N2yCD2omlpgEuPvfc0nJnZ5csdI2MOD1M8/mj S6LWm6WIM8x21Rpde8OwPEIiUjro8pJLG3eSB5dCKxlPXa/xRH2MYhBBNHI+75ElooFr A8hppXINcGHPn3edTGG618rNsQVM37r980Dc+Vqu3XOmG4eiDYvV0d+yXkAVEz+HxuOT 7+mxKrgmLf8v1R6kzX4/AS2NdEgml/dpbrwl6x3FC7XjnJQb2CHM1DBPU+czuZZCiT4T XMbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=sAVsOqt8V2XhMG+0Z1T8LZv+PSLwwD1tGqMAcz5FIh0=; fh=cOMsov2h/UE6XcTpm32BKIwR1PM/mYm6owF+PHemhXA=; b=iT6qL797EdsXL1T0/63Iza1aO9UvyeLoU8E1+nnFkQA9LPAKbUOH85E112aku7KJOp l804XnHnjwppX7osPEXBoyK+B1/FV+jCxxzxGZ5CdQJubx4UQ0IjPnnoAXahA98y72+t ZqYkHwzy9kcAZXQsRDbrUvGiNtOWBlh8PBCkaXOTZO+nTgHnzTGi64GKNGAN5mrruWmL j2H25G3m6Mm/oqblmKyMQ5D+p7Us3Qxrz4AdYzuYotW311c9I8a/7P2lwagVlHVQcOBz lghT/J8mJw9Cyst9WfudE1PrClzxvdze24KcRDWjXbjMS+isG8yz4PgQ++6JLA2VqX5q pJ8w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id v22-20020a17090ae99600b002839d007771si5069454pjy.55.2023.11.19.07.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 19 Nov 2023 07:12:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id C4137808ABA9; Sun, 19 Nov 2023 07:12:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231325AbjKSPMb (ORCPT + 99 others); Sun, 19 Nov 2023 10:12:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230027AbjKSPMa (ORCPT ); Sun, 19 Nov 2023 10:12:30 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11D7C138; Sun, 19 Nov 2023 07:12:25 -0800 (PST) X-UUID: 6c250ce1d55348c79c4c5818169f97d0-20231119 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.32,REQID:d4da5ac2-ed14-4e38-acb0-0604abae64ca,IP:5,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-10 X-CID-INFO: VERSION:1.1.32,REQID:d4da5ac2-ed14-4e38-acb0-0604abae64ca,IP:5,URL :0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:-10 X-CID-META: VersionHash:5f78ec9,CLOUDID:1a5a3a60-c89d-4129-91cb-8ebfae4653fc,B ulkID:231119230408XYBZ5UP2,BulkQuantity:1,Recheck:0,SF:19|44|64|66|24|17|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:40,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD X-UUID: 6c250ce1d55348c79c4c5818169f97d0-20231119 X-User: chentao@kylinos.cn Received: from [172.20.15.254] [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA) with ESMTP id 1611530766; Sun, 19 Nov 2023 23:12:10 +0800 Message-ID: <4b551600-f1a3-4efe-b3e9-99cb4536f487@kylinos.cn> Date: Sun, 19 Nov 2023 23:12:09 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH iwl-next] i40e: Use correct buffer size Content-Language: en-US To: Alexander Lobakin Cc: horms@kernel.org, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com, jesse.brandeburg@intel.com, kuba@kernel.org, kunwu.chan@hotmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, shannon.nelson@amd.com References: <20231113093112.GL705326@kernel.org> <20231115031444.33381-1-chentao@kylinos.cn> <55e07c56-da57-41aa-bc96-e446fad24276@intel.com> From: Kunwu Chan In-Reply-To: <55e07c56-da57-41aa-bc96-e446fad24276@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sun, 19 Nov 2023 07:12:41 -0800 (PST) Hi Alexander, Thank you so much for your reply, I looked at the modification you mentioned, it's really cool. I'll definitely try it next time. But when using it, will it be easy to forget to free up memory? Although 'kmalloc_track_caller' is used, according to my understanding, it is also necessary to release the memory at the end of use. On 2023/11/15 23:39, Alexander Lobakin wrote: > From: Kunwu Chan > Date: Wed, 15 Nov 2023 11:14:44 +0800 > >> The size of "i40e_dbg_command_buf" is 256, the size of "name" >> depends on "IFNAMSIZ", plus a null character and format size, >> the total size is more than 256, fix it. >> >> Signed-off-by: Kunwu Chan >> Suggested-by: Simon Horman >> --- >> drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c >> index 999c9708def5..e3b939c67cfe 100644 >> --- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c >> +++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c >> @@ -72,7 +72,7 @@ static ssize_t i40e_dbg_command_read(struct file *filp, char __user *buffer, >> { >> struct i40e_pf *pf = filp->private_data; >> int bytes_not_copied; >> - int buf_size = 256; >> + int buf_size = IFNAMSIZ + sizeof(i40e_dbg_command_buf) + 4; > > Reverse Christmas Tree style? Should be the first one in the declaration > list. > >> char *buf; >> int len; > > You can fix it in a different way. Given that there's a kzalloc() either > way, why not allocate the precise required amount of bytes by using > kasprintf() instead of kzalloc() + snprintf()? You wouldn't need to > calculate any buffer sizes etc. this way. > > Thanks, > Olek