Skip to content

Commit

Permalink
Merge tag 'staging-4.16-rc6' of git://git.kernel.org/pub/scm/linux/ke…
Browse files Browse the repository at this point in the history
…rnel/git/gregkh/staging

Pull staging fixes from Greg KH:
 "Here are three staging driver fixes for 4.16-rc6

  Two of them are lockdep fixes for the ashmem driver that have been
  reported by a number of people recently. The last one is a fix for the
  comedi driver core.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging:
  staging: android: ashmem: Fix possible deadlock in ashmem_ioctl
  staging: comedi: fix comedi_nsamples_left.
  staging: android: ashmem: Fix lockdep issue during llseek
  • Loading branch information
Linus Torvalds committed Mar 14, 2018
2 parents 1a7f749 + 740a575 commit 5e15d39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 15 deletions.
23 changes: 10 additions & 13 deletions drivers/staging/android/ashmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,24 +326,23 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
mutex_lock(&ashmem_mutex);

if (asma->size == 0) {
ret = -EINVAL;
goto out;
mutex_unlock(&ashmem_mutex);
return -EINVAL;
}

if (!asma->file) {
ret = -EBADF;
goto out;
mutex_unlock(&ashmem_mutex);
return -EBADF;
}

mutex_unlock(&ashmem_mutex);

ret = vfs_llseek(asma->file, offset, origin);
if (ret < 0)
goto out;
return ret;

/** Copy f_pos from backing file, since f_ops->llseek() sets it */
file->f_pos = asma->file->f_pos;

out:
mutex_unlock(&ashmem_mutex);
return ret;
}

Expand Down Expand Up @@ -702,16 +701,14 @@ static int ashmem_pin_unpin(struct ashmem_area *asma, unsigned long cmd,
size_t pgstart, pgend;
int ret = -EINVAL;

if (unlikely(copy_from_user(&pin, p, sizeof(pin))))
return -EFAULT;

mutex_lock(&ashmem_mutex);

if (unlikely(!asma->file))
goto out_unlock;

if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) {
ret = -EFAULT;
goto out_unlock;
}

/* per custom, you can pass zero for len to mean "everything onward" */
if (!pin.len)
pin.len = PAGE_ALIGN(asma->size) - pin.offset;
Expand Down
3 changes: 1 addition & 2 deletions drivers/staging/comedi/drivers.c
Original file line number Diff line number Diff line change
Expand Up @@ -475,8 +475,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
struct comedi_cmd *cmd = &async->cmd;

if (cmd->stop_src == TRIG_COUNT) {
unsigned int nscans = nsamples / cmd->scan_end_arg;
unsigned int scans_left = __comedi_nscans_left(s, nscans);
unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
unsigned int scan_pos =
comedi_bytes_to_samples(s, async->scan_progress);
unsigned long long samples_left = 0;
Expand Down

0 comments on commit 5e15d39

Please sign in to comment.