From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 61DDEA04F6 for ; Tue, 7 Jan 2020 09:43:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C4B61D939; Tue, 7 Jan 2020 09:43:33 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by dpdk.org (Postfix) with ESMTP id 00DC21D939 for ; Tue, 7 Jan 2020 09:43:31 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1578386611; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Q3nYgtg6+LpOSlm4G69z0LRcbbZdBgrbhfeJLCt7ag=; b=fxCdReWBKEDxiC1dsAG2goyL79zbhTAy90u3NpDUtKNW2LxS5HF/Mrhynmag8hpRSezm5i OG1lGrHqAPDyFptflN2pstzAabnRzBN0H+TSKX/hj0BIR1CNjooo8iZnrlPKsxJnjoCzJK Ph1Qd68AqwbMc+RB3fYhKYuHazTiyYs= Received: from mail-ua1-f72.google.com (mail-ua1-f72.google.com [209.85.222.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-5--YyihSTwPpayKwuQIkfoaw-1; Tue, 07 Jan 2020 03:43:29 -0500 Received: by mail-ua1-f72.google.com with SMTP id f15so5333669uap.4 for ; Tue, 07 Jan 2020 00:43:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cU1AyJrLwdCYE8WQWyRQwT4GkLHVHPMJilnxqO0Yi/E=; b=F532b+6mSf7bAo6IKD51bCX5pvhyNeN/WNyvGRsbW3rk44EQKjc6LaLeQ7P7Bg1kuZ uugB91/SIa1xiYY5tZF6GmdZc43KxSLYAeo7XnwuDSdpwQksIcdSc6BIzX0Tc4py+Xuv 4lDqHkHUZYC/hfCSWIqzW4CH9hc75WxyfxqxmBucy0ZmsuTonLmLFTT+7MxuYLjfu7cc qBH61U1io5GLyCw+fxp/sAobdVOJL5zmZsvb0ZZeSqUgTR/AVT3hEpvIqVZv4m7BxEDy LGjCqMP+ZZeM1//23ewB0lZ8v3rQaBsJR0T6HVALdXSHGIfqpo9X2kquRSxuJv5bpnJ4 gQlg== X-Gm-Message-State: APjAAAVbW947Z2YueZuxudaQE5aRs0myGpf0GYUPgTPdBjYJwqOJV6si MggWq8Zupqr7l73J3PD8vfjPoPB/iJledz95ATIJnpQNYyVk0n+vMMfYeRjkaXbzxEhXso2KnRr vSrvifHnNVAuhyKi8ygSHj48= X-Received: by 2002:ab0:2408:: with SMTP id f8mr56623290uan.126.1578386609436; Tue, 07 Jan 2020 00:43:29 -0800 (PST) X-Google-Smtp-Source: APXvYqzWu3payt0Q02mluyUW02XOKTg1erruniqVDYFErWVflGvIplHCfBCf0KaDBBjMtMvS/Zj4NTiJtyY2iTMS88c= X-Received: by 2002:ab0:2408:: with SMTP id f8mr56623285uan.126.1578386609126; Tue, 07 Jan 2020 00:43:29 -0800 (PST) MIME-Version: 1.0 References: <20200106205553.3696-1-stephen@networkplumber.org> In-Reply-To: <20200106205553.3696-1-stephen@networkplumber.org> From: David Marchand Date: Tue, 7 Jan 2020 09:43:17 +0100 Message-ID: To: Stephen Hemminger Cc: dev , "Burakov, Anatoly" , dpdk stable X-MC-Unique: -YyihSTwPpayKwuQIkfoaw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-stable] [PATCH] mem: fix incorrect munmap in error unwind X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On Mon, Jan 6, 2020 at 9:56 PM Stephen Hemminger wrote: > > The loop to unwind existing mmaps was only unmapping the > first segment. > > Also, remove obvious redundant assignment. > > Fixes: 66cc45e293ed ("mem: replace memseg with memseg lists") > Cc: anatoly.burakov@intel.com > Cc: stable@dpdk.org > Signed-off-by: Stephen Hemminger > --- > lib/librte_eal/linux/eal/eal_memory.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/lib/librte_eal/linux/eal/eal_memory.c b/lib/librte_eal/linux= /eal/eal_memory.c > index 43e4ffc757bd..cf5b2433614b 100644 > --- a/lib/librte_eal/linux/eal/eal_memory.c > +++ b/lib/librte_eal/linux/eal/eal_memory.c > @@ -1967,9 +1967,8 @@ eal_legacy_hugepage_attach(void) > close(fd); > error: > /* map all segments into memory to make sure we get the addrs */ This looks like a copy of the same loop from a few lines before in the same function. The comment can be removed. > - cur_seg =3D 0; > for (cur_seg =3D 0; cur_seg < i; cur_seg++) { > - struct hugepage_file *hf =3D &hp[i]; > + struct hugepage_file *hf =3D &hp[cur_seg]; > size_t map_sz =3D hf->size; > void *map_addr =3D hf->final_va; > map_addr and map_sz are unnecessary. We should be safe with dereferencing hp if i !=3D 0, but still how about: error: if (hp !=3D NULL && hp !=3D MAP_FAILED) { unsigned int cur_seg; for (cur_seg =3D 0; cur_seg < i; cur_seg++) munmap(hp[cur_seg].final_va, hp[cur_seg].size); munmap(hp, size); } if (fd_hugepage >=3D 0) close(fd_hugepage); return -1; --=20 David Marchand