From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A7790A056B; Mon, 21 Nov 2022 21:40:47 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0B0EC42D41; Mon, 21 Nov 2022 21:40:36 +0100 (CET) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mails.dpdk.org (Postfix) with ESMTP id B422642D2F for ; Mon, 21 Nov 2022 21:40:33 +0100 (CET) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 3D62661466 for ; Mon, 21 Nov 2022 20:40:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3B68C433D6; Mon, 21 Nov 2022 20:40:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669063233; bh=la40dExgi0dR4Z07BhXzPuvIKB5xFFiP17RRztKKQUI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TyX2zeKA16o3rZNO7tGh5iPXXLcQrXsLMB28Mg9QBUXzticMjynPNWfW8XqChILik VaJ9WAcyodRkjYgb+RLnpNni90rzFczy49zzFauC9S5zSvLr4XgB6vjbzkq/E/a7wj GCHzmSFix1+J6AGAJ5E+Wz+Vd4HP/77hTY0YnfR5sptT+VNtemx2TJK7r38HoXeDxt 1H0gu3nFhvSgMmc4s7l82Ou7jomq7h23mumNc06v16BreBZ0aTHcWyyu67+mVkIovh m9yrwDC3HwiIs4vg2lXCmphbUOcSD5KkYRF6zRqIKE3S+1KFaTzf1uC9oLeXY+GTVM P4wCU5VplMNYw== From: okaya@kernel.org To: dev@dpdk.org Cc: Sinan Kaya Subject: [PATCH 04/11] memzone: check result of malloc_elem_from_data Date: Mon, 21 Nov 2022 15:40:10 -0500 Message-Id: <20221121204015.1135573-5-okaya@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221121204015.1135573-1-okaya@kernel.org> References: <20221121204015.1135573-1-okaya@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Sinan Kaya In memzone_reserve_aligned_thread_unsafe result of call to malloc_elem_from_data is dereferenced here and may be null. Signed-off-by: Sinan Kaya --- lib/eal/common/eal_common_memzone.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/eal/common/eal_common_memzone.c b/lib/eal/common/eal_common_memzone.c index 0ed03ad337..74aa5ac114 100644 --- a/lib/eal/common/eal_common_memzone.c +++ b/lib/eal/common/eal_common_memzone.c @@ -169,6 +169,10 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, } struct malloc_elem *elem = malloc_elem_from_data(mz_addr); + if (!elem) { + rte_errno = ENOSPC; + return NULL; + } /* fill the zone in config */ mz_idx = rte_fbarray_find_next_free(arr, 0); -- 2.25.1