Message ID | 20230208093016.20670-2-ilpo.jarvinen@linux.intel.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp3355649wrn; Wed, 8 Feb 2023 01:33:04 -0800 (PST) X-Google-Smtp-Source: AK7set9WcKPe1w3m6SmIEQIKCLyq/CAVufK19i0Q4XwtFrXJWOHc8GUpCr0UZ2vYUqxJIEjnmLEu X-Received: by 2002:a62:1792:0:b0:592:705a:5a5e with SMTP id 140-20020a621792000000b00592705a5a5emr5819587pfx.9.1675848783919; Wed, 08 Feb 2023 01:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1675848783; cv=none; d=google.com; s=arc-20160816; b=UmU4uowglahnsrr/Mi8RBwF0AyBvQAsypM05w7mAhKbfv2iae7xZ2WgaYPO2r7k/am hlGnohCgNdSXR4ab9FXzy+wBt5YH13OT86fHPGrZddOzXu5Ij4ljJ8f9tzGnGU3hUIm1 1n2slcZkdHrbtJHNwh40Kg8AVqZ8quR23KtS/4PkcTGKrWkhSs3GT8oCrSoZL67GZ9lR daM1pEKwOlepGz6M0YqLRAgfrnUnqIrYgECJzjk4BwbtHxhik0Iz9O3g+2TcEnr7rRWM EnhwBric9JfSJ8WvBIrTPRy6BuOjUvg8ZeOTUcPW2GGVzJlTbWxeoOevvdXp++Q0nWFc 8IRg== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=POZIMx4cfKB1YxjIeohVJ0GGv+Vcpea4G7mA6nU12F0=; b=yh8RRJBwaeubWTEopR0NaEb1WZGR6X951DCF9jldZXL52avvlW3xYBSEPwZXdiw+Ia oczvVuLVFxEj2v9WGN5uAo2Fssp2tYdHJUw5zMb0yKuBaukOGxu7sfWWigusm6+RMpPO 2B/FzzrX38TRZUlrJto3e1VpVkxK6Hx/Z6rr2Bfc+Wh+gEAUzt9ZaFtBlDdyEkEp9Ba7 /caWCF2cac1YRJyJdLDkfoAXqBYnNX5lqbq9PTbawRUjeFVL1pYLrW2TSyG2uE+ioTBt i/0U9paK9F1rMgIxYdDSjd4G9D4tJcP8TIVOeNOYJ2UWkj0WuGLLUy3T/qCYfJsT+sh4 IgkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DHqyuRlJ; 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=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a23-20020aa794b7000000b005a70bd64eabsi5303084pfl.46.2023.02.08.01.32.51; Wed, 08 Feb 2023 01:33:03 -0800 (PST) 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=@intel.com header.s=Intel header.b=DHqyuRlJ; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230469AbjBHJbb (ORCPT <rfc822;kmanaouilinux@gmail.com> + 99 others); Wed, 8 Feb 2023 04:31:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbjBHJbM (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 8 Feb 2023 04:31:12 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F07545F67; Wed, 8 Feb 2023 01:30:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675848631; x=1707384631; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=TRBoRdV3a9jOZVWAFY2ULLzhstU2pVvPebTVTTjpfxE=; b=DHqyuRlJAnYH5HKe+KtEj56wxt7U5KVrJ5vmA+Ql7NzY3lfNhCX7XTzd /fMaFvGJFDT7UOw+PxycNgBANO40CQBe2h2Qk2ELvLm5SjPGwA/l+8/kR U1WZFz5Rqqz68Fupr2t7rFXzZ9Ns/HD9TbCdubSdlUIP97VkkVC/xOuMT T+9KWiPmtCj8hWgObk1Ig2x1jQqxGvgBfAITdXmDJhgviKDL8cr2lSlmr h/3Rc+BdDwS9RQ4gV/WssYR0ImMUKcG6tX281F2X5tnZ4YxZ6lDYePvHX vleYCBiZtGcUdrOycn/O1mgp9Sp8g+D2fnn6i/x2LpCgGZMWBADbq0nfA A==; X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="415974499" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="415974499" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:30 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10614"; a="697613865" X-IronPort-AV: E=Sophos;i="5.97,280,1669104000"; d="scan'208";a="697613865" Received: from jstelter-mobl.ger.corp.intel.com (HELO ijarvine-MOBL2.ger.corp.intel.com) ([10.252.38.39]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2023 01:30:27 -0800 From: =?utf-8?q?Ilpo_J=C3=A4rvinen?= <ilpo.jarvinen@linux.intel.com> To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre <reinette.chatre@intel.com>, Fenghua Yu <fenghua.yu@intel.com>, Shuah Khan <shuah@kernel.org>, Babu Moger <babu.moger@amd.com>, Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com> Subject: [PATCH 1/4] selftests/resctrl: Return error if memory is not allocated Date: Wed, 8 Feb 2023 11:30:13 +0200 Message-Id: <20230208093016.20670-2-ilpo.jarvinen@linux.intel.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> References: <20230208093016.20670-1-ilpo.jarvinen@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757254814441890206?= X-GMAIL-MSGID: =?utf-8?q?1757254814441890206?= |
Series |
selftests/resctrl: Fixes to error handling logic
|
|
Commit Message
Ilpo Järvinen
Feb. 8, 2023, 9:30 a.m. UTC
From: Fenghua Yu <fenghua.yu@intel.com> malloc_and_init_memory() in fill_buf isn't checking if memalign() successfully allocated memory or not before accessing the memory. Check the return value of memalign() and return NULL if allocating aligned memory fails. Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark") Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> --- tools/testing/selftests/resctrl/fill_buf.c | 2 ++ 1 file changed, 2 insertions(+)
Comments
Hi Ilpo, I do not see a why two patch series are needed for the resctrl fixes. It may make it easier for everybody if it is handled as one patch series (with fixes first)? On 2/8/2023 1:30 AM, Ilpo Järvinen wrote: > From: Fenghua Yu <fenghua.yu@intel.com> > > malloc_and_init_memory() in fill_buf isn't checking if memalign() > successfully allocated memory or not before accessing the memory. > > Check the return value of memalign() and return NULL if allocating > aligned memory fails. > > Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark") > Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Missing your Signed-off-by? > --- > tools/testing/selftests/resctrl/fill_buf.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c > index 56ccbeae0638..f4880c962ec4 100644 > --- a/tools/testing/selftests/resctrl/fill_buf.c > +++ b/tools/testing/selftests/resctrl/fill_buf.c > @@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s) > size_t s64; > > void *p = memalign(PAGE_SIZE, s); This may also be a good time to stop using an obsolete call? > + if (!p) > + return p; Could you please return NULL explicitly? > > p64 = (uint64_t *)p; > s64 = s / sizeof(uint64_t); Reinette
On Mon, 13 Feb 2023, Reinette Chatre wrote: > I do not see a why two patch series are needed for > the resctrl fixes. It may make it easier for everybody if > it is handled as one patch series (with fixes first)? Ok, I can put the fixes and cleanups into one series. > On 2/8/2023 1:30 AM, Ilpo Järvinen wrote: > > From: Fenghua Yu <fenghua.yu@intel.com> > > > > malloc_and_init_memory() in fill_buf isn't checking if memalign() > > successfully allocated memory or not before accessing the memory. > > > > Check the return value of memalign() and return NULL if allocating > > aligned memory fails. > > > > Fixes: a2561b12fe39 ("selftests/resctrl: Add built in benchmark") > > Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> > > Missing your Signed-off-by? These were intentionally. When I didn't modify the original patch at all during forward porting it, I just kept the original From and SoB as is. But from the doc you pointed me to, I see now x86 wants also handlers sobs. > > --- > > tools/testing/selftests/resctrl/fill_buf.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c > > index 56ccbeae0638..f4880c962ec4 100644 > > --- a/tools/testing/selftests/resctrl/fill_buf.c > > +++ b/tools/testing/selftests/resctrl/fill_buf.c > > @@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s) > > size_t s64; > > > > void *p = memalign(PAGE_SIZE, s); > > This may also be a good time to stop using an obsolete call? Sure, I can add another patch to change that to posix_memalign(). > > + if (!p) > > + return p; > > Could you please return NULL explicitly? I'll change it. Thanks for you comments.
Hi Ilpo, On 2/14/2023 1:32 AM, Ilpo Järvinen wrote: > On Mon, 13 Feb 2023, Reinette Chatre wrote: >> Missing your Signed-off-by? > > These were intentionally. When I didn't modify the original patch at > all during forward porting it, I just kept the original From and SoB as > is. But from the doc you pointed me to, I see now x86 wants also handlers > sobs. I do not think this is x86 specific. Documentation/process/submitting-patches.rst states: "Any further SoBs (Signed-off-by:'s) following the author's SoB are from people handling and transporting the patch, but were not involved in its development. SoB chains should reflect the **real** route a patch took as it was propagated to the maintainers and ultimately to Linus, with the first SoB entry signalling primary authorship of a single author." > >>> --- >>> tools/testing/selftests/resctrl/fill_buf.c | 2 ++ >>> 1 file changed, 2 insertions(+) >>> >>> diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c >>> index 56ccbeae0638..f4880c962ec4 100644 >>> --- a/tools/testing/selftests/resctrl/fill_buf.c >>> +++ b/tools/testing/selftests/resctrl/fill_buf.c >>> @@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s) >>> size_t s64; >>> >>> void *p = memalign(PAGE_SIZE, s); >> >> This may also be a good time to stop using an obsolete call? > > Sure, I can add another patch to change that to posix_memalign(). You can also consider aligned_alloc(). Reinette
diff --git a/tools/testing/selftests/resctrl/fill_buf.c b/tools/testing/selftests/resctrl/fill_buf.c index 56ccbeae0638..f4880c962ec4 100644 --- a/tools/testing/selftests/resctrl/fill_buf.c +++ b/tools/testing/selftests/resctrl/fill_buf.c @@ -68,6 +68,8 @@ static void *malloc_and_init_memory(size_t s) size_t s64; void *p = memalign(PAGE_SIZE, s); + if (!p) + return p; p64 = (uint64_t *)p; s64 = s / sizeof(uint64_t);