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 5724C42C52; Wed, 7 Jun 2023 18:49:25 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 4784842C76; Wed, 7 Jun 2023 18:49:25 +0200 (CEST) Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by mails.dpdk.org (Postfix) with ESMTP id 165F542C4D for ; Wed, 7 Jun 2023 18:49:24 +0200 (CEST) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-662f0feafb2so76408b3a.1 for ; Wed, 07 Jun 2023 09:49:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20221208.gappssmtp.com; s=20221208; t=1686156563; x=1688748563; 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=aTWkAAAjdQghUCRwplMVVgh+VPMNuleD52+WzbqOiBg=; b=jv9c28BpE/ajtm3acXEr6CGoBeU2CerT4LS32V4bzf2yLpVALoR9qFOgKKk162TJWs nNxwAj2SItN4bakaj8ydaP2mfbt4inhXWI/QUIx/WWyrCUHhLkQlDG04dUVkxWLB5fSG EW83Z5YRbLpYFsECLyk1JdPDzhr9GjKs2W0+14PjgyO315JNQCPp3JTOnBca8rkKbjpi yY/GLvXur4WtwDkpPWczGw5aLI1xVS1YMWb9Q0xUPczdNXsuwdOLKOyHsUiqK439/Vp5 sQ/nR5qZ8S1FOeIwJ/SSpe5w4rqkkhznOlqYE6TYL2tIBzvyRtmuBJbpzAB/b9fYGz2V JWwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686156563; x=1688748563; 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=aTWkAAAjdQghUCRwplMVVgh+VPMNuleD52+WzbqOiBg=; b=Yqw1+Usc0XuXQvOj6M0e5kQi+/gPpzJWRY9kIDo7R9+DnxVqWqT5eQMVeP4szLeML8 Em1NpO7doSjh4jgWseTZGLhxL+un7i49UMgBvlcx4yQNOyuiTQZKnLI5hTngbWK8Ks/H OkxK7M9OaTAPX8h28meSRgfyETA54eNSrBfCdNfA/V25mZjH+O8oICmlXf/Z0EvZBlLg TqAwINgwQqTzSdouHIj6jFgoT/ljLpI23VfpaqDJbyjQGxstwCM8YqALLD2YmiihXz+O Tv4Ak6ZvRi6fAbdk8S8qQ9b1o8fEzIlV87pT4dTKcQmWmYQ/NPunF19iLUt9gYLtduNC sfAQ== X-Gm-Message-State: AC+VfDz1YJUHyoG1qZ10EkJHSghlee6eKFVY76Kj0mZbngwpfo+1p73j ztv9VR6fuhJCTMnMj4qrbJzgDQ== X-Google-Smtp-Source: ACHHUZ4pw1fVZ1U6b9RtyKbRDqlYominMnK2pHRr+ZH4m5INteDYR0lYEBj6cnYFNBvb3tXHApZMSg== X-Received: by 2002:a05:6a20:7f8c:b0:ff:ca91:68ee with SMTP id d12-20020a056a207f8c00b000ffca9168eemr3924549pzj.9.1686156563282; Wed, 07 Jun 2023 09:49:23 -0700 (PDT) Received: from hermes.local (204-195-120-218.wavecable.com. [204.195.120.218]) by smtp.gmail.com with ESMTPSA id x41-20020a056a000be900b006468222af91sm8683891pfu.48.2023.06.07.09.49.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Jun 2023 09:49:23 -0700 (PDT) Date: Wed, 7 Jun 2023 09:49:21 -0700 From: Stephen Hemminger To: Srikanth Yalavarthi Cc: Anup Prabhu , , , Subject: Re: [PATCH v5] app/mldev: add internal function for file read Message-ID: <20230607094921.5b8b63c7@hermes.local> In-Reply-To: <20230607162030.3004-1-syalavarthi@marvell.com> References: <20230323152801.27666-1-syalavarthi@marvell.com> <20230607162030.3004-1-syalavarthi@marvell.com> 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 On Wed, 7 Jun 2023 09:20:30 -0700 Srikanth Yalavarthi wrote: The normal case leaks the open file descriptor + + file_map = mmap(0, file_stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0); + if (file_map == MAP_FAILED) { + ml_err("Failed to map file: %s\n", file); + ret = -errno; + goto error; + } + + rte_memcpy(file_buffer, file_map, file_stat.st_size); + munmap(file_map, file_stat.st_size); + + *size = file_stat.st_size; + *buffer = file_buffer; + + return 0; Missing close() > + if (buffer) > + free(buffer); > + Another needless if()