[EXT] Re: [PATCH v5] app/mldev: add internal function for file read
Srikanth Yalavarthi
syalavarthi at marvell.com
Wed Jun 7 19:24:46 CEST 2023
> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: 07 June 2023 22:19
> To: Srikanth Yalavarthi <syalavarthi at marvell.com>
> Cc: Anup Prabhu <aprabhu at marvell.com>; dev at dpdk.org; Shivah Shankar
> Shankar Narayan Rao <sshankarnara at marvell.com>; Prince Takkar
> <ptakkar at marvell.com>
> Subject: [EXT] Re: [PATCH v5] app/mldev: add internal function for file read
>
> External Email
>
> ----------------------------------------------------------------------
> On Wed, 7 Jun 2023 09:20:30 -0700
> Srikanth Yalavarthi <syalavarthi at marvell.com> 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()
Updated in v6.
More information about the dev
mailing list