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 E47E7A0582; Tue, 22 Nov 2022 16:52:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6099442D93; Tue, 22 Nov 2022 16:52:38 +0100 (CET) Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by mails.dpdk.org (Postfix) with ESMTP id 1C84342D97 for ; Tue, 22 Nov 2022 16:52:37 +0100 (CET) Received: by mail-lf1-f53.google.com with SMTP id f13so2656860lfa.6 for ; Tue, 22 Nov 2022 07:52:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=aZXIaqyUOy/4m8BfcZjPc5Q5AfmUk+cdL2xquHFEZes=; b=MtrBCshJXxybjzOJ/13AE+7d9awHSdd4Eak9AkbwK8trAs02qv1qcCTgvhTMvYbD9+ hjwOEYlgVnM8HD05FkY3YvizCfR4AHOgiS/Zxx2ntLJNCFtBY2s00u2Kv5T3DXWEpP75 wFHpMHDTXlpwWvGnivOBE6iOVoXxl2mUaTj24RhKHbb1lokT3Zbf1Ju3+22rj+ah5IBe EK9s1agpPfBjoLDF/nwPctYSblCKM1Po4JNF0/f2MTzcUKI7OxYVgFe3cZj/GB3H7oNT H+dN4LerSWOgE9HGIsZLxXUF3HFQmdOkisfVB5iRx8I6Ar0I9qVBAI/Frw3NbvYMMG1a k+nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=aZXIaqyUOy/4m8BfcZjPc5Q5AfmUk+cdL2xquHFEZes=; b=TsXyQJUK4R6GGyJ+jVswcYZwDRXxwhdaRgylovxuA/F8wxsfqRvra9qDPuJdfTf8vd C5VnRUwv95TBy3uArocwWodziq91yZfGNTqWOBQkxBhH1E9R7S5PuSVQxTgE/RjW8hVn Dg+KBDuj4blX/IICkS0LVA22e6m7cuQurLTdFQYFbPHm3VwP1u3EVcRpTbd+4CyHQsSS B7k/lxZPBUJS2cc9j8FV7ZyJHHW5kf/i4kbVcPDPfPmedGKcVpM2gGUa2cxLcaknzKrQ v79V3ugPgBsLMN3Wv6tAgsiMcwhpV+/MqRhmTEsm4ntOul8gUz7NUNO7n09fh2xwsVVi hL9g== X-Gm-Message-State: ANoB5plvX9z6z/9Ycqg2/NzeNhQ3BJjlOXCNdVHaBd+VXpYqwat4rmvj Lo0faK87QRp/9GNKkGGWzaUWtzMlZyI= X-Google-Smtp-Source: AA0mqf56LUpqkZ0Sf+8UpFU4JaVn9P1eQvCaWsH3CVu/WNKS0gCp2ONK+xBOFZyevNeztDYQjAlAFg== X-Received: by 2002:ac2:4bd4:0:b0:4b4:aed7:4aa5 with SMTP id o20-20020ac24bd4000000b004b4aed74aa5mr2325765lfq.447.1669132356500; Tue, 22 Nov 2022 07:52:36 -0800 (PST) Received: from sovereign (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id p11-20020a2e740b000000b00277129b4a10sm1893213ljc.86.2022.11.22.07.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Nov 2022 07:52:36 -0800 (PST) Date: Tue, 22 Nov 2022 18:52:35 +0300 From: Dmitry Kozlyuk To: okaya@kernel.org Cc: dev@dpdk.org Subject: Re: [PATCH v2 07/11] malloc: check result of rte_fbarray_get Message-ID: <20221122185235.76014488@sovereign> In-Reply-To: <20221121223208.1147154-8-okaya@kernel.org> References: <20221121223208.1147154-1-okaya@kernel.org> <20221121223208.1147154-8-okaya@kernel.org> X-Mailer: Claws Mail 3.18.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit 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 2022-11-21 17:32 (UTC-0500), okaya@kernel.org: > From: Sinan Kaya > > In eal_memalloc_is_contig result of call to rte_fbarray_get > is dereferenced here and may be null. > > Signed-off-by: Sinan Kaya > --- > lib/eal/common/eal_common_memalloc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/lib/eal/common/eal_common_memalloc.c b/lib/eal/common/eal_common_memalloc.c > index ab04479c1c..24506f8447 100644 > --- a/lib/eal/common/eal_common_memalloc.c > +++ b/lib/eal/common/eal_common_memalloc.c > @@ -126,6 +126,9 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, > > /* skip first iteration */ > ms = rte_fbarray_get(&msl->memseg_arr, start_seg); > + if (ms == NULL) > + return false; > + > cur = ms->iova; > expected = cur + pgsz; > > @@ -137,7 +140,7 @@ eal_memalloc_is_contig(const struct rte_memseg_list *msl, void *start, > cur_seg++, expected += pgsz) { > ms = rte_fbarray_get(&msl->memseg_arr, cur_seg); > > - if (ms->iova != expected) > + if ((ms != NULL) && (ms->iova != expected)) > return false; > } > } Invariant: "msl->memseg_arr" elements for existing memsegs are used. RTE_ASSERT(rte_fbarray_is_used(&msl->memseg_arr, ...)) would be sufficient.