> -----Original Message----- > From: Stephen Hemminger <[email protected]> > Sent: 07 June 2023 22:19 > To: Srikanth Yalavarthi <[email protected]> > Cc: Anup Prabhu <[email protected]>; [email protected]; Shivah Shankar > Shankar Narayan Rao <[email protected]>; Prince Takkar > <[email protected]> > 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 <[email protected]> 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.

