All of lore.kernel.org
 help / color / mirror / Atom feed
* [BUG] fs: cifs : does there exist a memleak in function cifs_writev_requeue
@ 2020-04-20  9:20 亿一
  2020-04-20 11:04 ` Aurélien Aptel
  0 siblings, 1 reply; 2+ messages in thread
From: 亿一 @ 2020-04-20  9:20 UTC (permalink / raw)
  To: sfrench; +Cc: linux-cifs

Hi all:
 When reviewing the code of function cifs_writev_requeue, wdata2
allocated in while loop.
however,  if wdata2->cfile is NULL, the loop break without release
wdata2, there exists a memleak of wdata2?

static void
cifs_writev_requeue(struct cifs_writedata *wdata)
{
......
      wdata2 = cifs_writedata_alloc(nr_pages, cifs_writev_complete);
    // allocate wdata2
      if (!wdata2) {
             rc = -ENOMEM;
             break;
      }

      for (j = 0; j < nr_pages; j++) {
          wdata2->pages[j] = wdata->pages[i + j];
          lock_page(wdata2->pages[j]);
          clear_page_dirty_for_io(wdata2->pages[j]);
      }

      wdata2->sync_mode = wdata->sync_mode;
      wdata2->nr_pages = nr_pages;
      wdata2->offset = page_offset(wdata2->pages[0]);
      wdata2->pagesz = PAGE_SIZE;
      wdata2->tailsz = tailsz;
      wdata2->bytes = cur_len;

      wdata2->cfile = find_writable_file(CIFS_I(inode), false);
      if (!wdata2->cfile) {
            cifs_dbg(VFS, "No writable handles for inode\n");
            rc = -EBADF;
            break;                         // break without release wdata2.
      }
      ......
      }  while (i < wdata->nr_pages);

      mapping_set_error(inode->i_mapping, rc);
      kref_put(&wdata->refcount, cifs_writedata_release);
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-20 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-20  9:20 [BUG] fs: cifs : does there exist a memleak in function cifs_writev_requeue 亿一
2020-04-20 11:04 ` Aurélien Aptel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.