[BUG] fs: cifs : does there exist a memleak in function cifs_writev_requeue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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);
 }



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux