Skip to content

Commit

Permalink
Copy msg buffer back to userspace on ENOMEM.
Browse files Browse the repository at this point in the history
  • Loading branch information
dacut committed Jun 14, 2016
1 parent e94b0df commit 2e25a3c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client/ublkdev-c++/s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,11 @@ void UBDS3Handler::run() {
if (e.getError() == ENOMEM) {
// Resize the buffer
try {
cerr << "ENOMEM -- allocated " << m_buffer_size
<< " bytes but need " << m_message.ubd_size
<< " bytes" << endl;
resizeBuffer(m_message.ubd_size);
cerr << "Now have " << m_buffer_size << " bytes" << endl;
}
catch (bad_alloc &) {
cerr << "Thread " << std::this_thread::get_id()
Expand Down
1 change: 1 addition & 0 deletions src/ublkdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,6 +964,7 @@ static long ubdctl_ioctl_getrequest(
ubd_warning("Insufficient buffer space: need %u bytes; userspace "
"provided only %u bytes.", write_size, msg.ubd_size);
msg.ubd_size = write_size;
copy_to_user((void *) data, &msg, sizeof(msg));
spin_unlock_irqrestore(&dev->wait.lock, lock_flags);
return -ENOMEM;
}
Expand Down

0 comments on commit 2e25a3c

Please sign in to comment.