From patchwork Wed Feb 8 09:30:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ilpo_J=C3=A4rvinen?= X-Patchwork-Id: 652228 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D285C636CC for ; Wed, 8 Feb 2023 09:31:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230456AbjBHJba (ORCPT ); Wed, 8 Feb 2023 04:31:30 -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 ); 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?= To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Reinette Chatre , Fenghua Yu , Shuah Khan , Babu Moger , Sai Praneeth Prakhya 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 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: Fenghua Yu 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 --- 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); + if (!p) + return p; p64 = (uint64_t *)p; s64 = s / sizeof(uint64_t);