Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp558248pxb; Wed, 11 Nov 2020 10:13:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxdJhwH7bxCcFF58XvpFP2ImULPcznfdjGULweqZVkjCgfL5rnzhPIn8IGSqWqw9AzWghP X-Received: by 2002:a50:9e86:: with SMTP id a6mr789227edf.238.1605118427455; Wed, 11 Nov 2020 10:13:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605118427; cv=none; d=google.com; s=arc-20160816; b=0nMRX3zLYG/dvocDIs/wbDYoBDji1hC4waKrrdCxBIExvj6MGjPgCg0nvYEOPETlU5 Y59YQ2NrSg+aLRLaMxDNzsM8Rn7A6Vn+Q7HN+Mn+QR64C+rujfkgSqDwgpbFDauU5IVy qs0tDic/cYjdf6yTneywXEro7MgroXbqWYL83tCa4HGrmGucisQDpcIxjAvOriTdLvuv VCWEz6HtPvbTGLmnG12ziN+vTAsUTwKgI5PNiwdnL2Pky/9ivHSHfsMvHb/C+M1svhFm Ij5ttFxy10u55ZoOwt5prpNh3YqEjPW5QAh/GPXOIbw5IPNEHY1J4BVlKg6Q9mn4G9Gz Cf/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=kUuq3ZAat0+OFLO7qIsihf0UYtD+64WlcB+QLOid7z8=; b=STrQLAO0M3nATDUd1Hge5OaLOr2+CHUNpyb7DlusYPfsvLRzVwl1Dx6izqfm4ZUdz5 p8zUiN8kFsihdK9+ZJT4HWyKbzO6vhGq4DtLfhF/clVMm4qsZBg+FR+ZiBAKx9ffS3hy PCwdf9H2V6GDqwoMBELqeffQis8Ou/nBVWNHvBY7EwQHegO1Zi4Ps/khBXE/cVzJ9PcE CxCXdpFHEAtIKZR3MHtyXU6hDD1V7YcnEJeEHee9aPxoCE5pT88wIQg4IQ+WCffaHtlJ HjTZ1eFQDAku468/ee6eLN/astFxVNXfZKjbWFWCsgf50ER1VX0Vuz9gFNcQ4uiww0rs WriA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i6si2347709ejs.300.2020.11.11.10.13.20; Wed, 11 Nov 2020 10:13:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726136AbgKKSLl (ORCPT + 99 others); Wed, 11 Nov 2020 13:11:41 -0500 Received: from foss.arm.com ([217.140.110.172]:59444 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbgKKSLl (ORCPT ); Wed, 11 Nov 2020 13:11:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A240C142F; Wed, 11 Nov 2020 10:11:40 -0800 (PST) Received: from [172.16.1.113] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 229A83F718; Wed, 11 Nov 2020 10:11:39 -0800 (PST) Subject: Re: [PATCH 10/24] x86/resctrl: Move the schema names into struct resctrl_schema To: Jamie Iles Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS References: <20201030161120.227225-1-james.morse@arm.com> <20201030161120.227225-11-james.morse@arm.com> <20201110113922.GA94467@poplar> From: James Morse Message-ID: <45b6313b-eef3-86ff-f27e-8630c2e19288@arm.com> Date: Wed, 11 Nov 2020 18:11:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <20201110113922.GA94467@poplar> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jamie, Thanks for taking a look, On 10/11/2020 11:39, Jamie Iles wrote: > On Fri, Oct 30, 2020 at 04:11:06PM +0000, James Morse wrote: >> Move the names used for the schemata file out of the resource and >> into struct resctrl_schema. This allows one resource to have two >> different names, based on the other schema properties. >> >> This patch copies the names, eventually resctrl will generate them. >> >> Remove the arch code's max_name_width, this is now resctrl's >> problem. >> diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> index 311a3890bc53..48f4d6783647 100644 >> --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c >> @@ -2150,6 +2151,12 @@ static int create_schemata_list(void) >> s->num_closid = resctrl_arch_get_num_closid(r); >> s->conf_type = resctrl_to_arch_res(r)->conf_type; >> >> + ret = snprintf(s->name, sizeof(s->name), r->name); >> + if (ret >= sizeof(s->name)) { >> + kfree(s); >> + return -EINVAL; >> + } >> + > > How about: > > + ret = strscpy(s->name, r->name, sizeof(s->name)); > + if (ret < 0)) { > + kfree(s); > + return -EINVAL; > + } Never heard of it ... yup, that looks better. Thanks! (I thought I knew not to write that bug!) > So that there isn't a non-constant format specifier that'll trip > Coverity+friends up later? Heh, its gone by the last patch. Fixed locally. Thanks, James