Skip to content

Commit 5e15d39

Browse files
committed
Merge tag 'staging-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/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
2 parents 1a7f749 + 740a575 commit 5e15d39

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

drivers/staging/android/ashmem.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -326,24 +326,23 @@ static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin)
326326
mutex_lock(&ashmem_mutex);
327327

328328
if (asma->size == 0) {
329-
ret = -EINVAL;
330-
goto out;
329+
mutex_unlock(&ashmem_mutex);
330+
return -EINVAL;
331331
}
332332

333333
if (!asma->file) {
334-
ret = -EBADF;
335-
goto out;
334+
mutex_unlock(&ashmem_mutex);
335+
return -EBADF;
336336
}
337337

338+
mutex_unlock(&ashmem_mutex);
339+
338340
ret = vfs_llseek(asma->file, offset, origin);
339341
if (ret < 0)
340-
goto out;
342+
return ret;
341343

342344
/** Copy f_pos from backing file, since f_ops->llseek() sets it */
343345
file->f_pos = asma->file->f_pos;
344-
345-
out:
346-
mutex_unlock(&ashmem_mutex);
347346
return ret;
348347
}
349348

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

704+
if (unlikely(copy_from_user(&pin, p, sizeof(pin))))
705+
return -EFAULT;
706+
705707
mutex_lock(&ashmem_mutex);
706708

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

710-
if (unlikely(copy_from_user(&pin, p, sizeof(pin)))) {
711-
ret = -EFAULT;
712-
goto out_unlock;
713-
}
714-
715712
/* per custom, you can pass zero for len to mean "everything onward" */
716713
if (!pin.len)
717714
pin.len = PAGE_ALIGN(asma->size) - pin.offset;

drivers/staging/comedi/drivers.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,7 @@ unsigned int comedi_nsamples_left(struct comedi_subdevice *s,
475475
struct comedi_cmd *cmd = &async->cmd;
476476

477477
if (cmd->stop_src == TRIG_COUNT) {
478-
unsigned int nscans = nsamples / cmd->scan_end_arg;
479-
unsigned int scans_left = __comedi_nscans_left(s, nscans);
478+
unsigned int scans_left = __comedi_nscans_left(s, cmd->stop_arg);
480479
unsigned int scan_pos =
481480
comedi_bytes_to_samples(s, async->scan_progress);
482481
unsigned long long samples_left = 0;

0 commit comments

Comments
 (0)