From: Jiri Slaby <jslaby@suse.cz>
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Ian Abbott <abbotti@mev.co.uk>,
Jiri Slaby <jslaby@suse.cz>
Subject: [PATCH 3.12 04/84] staging: comedi: usbduxsigma: don't clobber ao_timer in command test
Date: Fri, 2 Oct 2015 15:24:09 +0200 [thread overview]
Message-ID: <92ca2aaa4cc43fd8bb1cd018d7183a2d68352b2e.1443792303.git.jslaby@suse.cz> (raw)
In-Reply-To: <4386f737d429451d61358f771e315ed47e2f451f.1443792303.git.jslaby@suse.cz>
In-Reply-To: <cover.1443792303.git.jslaby@suse.cz>
From: Ian Abbott <abbotti@mev.co.uk>
3.12-stable review patch. If anyone has any objections, please let me know.
===============
commit c04a1f17803e0d3eeada586ca34a6b436959bc20 upstream
`devpriv->ao_timer` is used while an asynchronous command is running on
the AO subdevice. It also gets modified by the subdevice's `cmdtest`
handler for checking new asynchronous commands,
`usbduxsigma_ao_cmdtest()`, which is not correct as it's allowed to
check new commands while an old command is still running. Fix it by
moving the code which sets up `devpriv->ao_timer` into the subdevice's
`cmd` handler, `usbduxsigma_ao_cmd()`.
** This backported patch also moves the code that sets up
`devpriv->ao_sample_count` and `devpriv->ao_continuous` from
`usbduxsigma_ao_cmdtest()` to `usbduxsigma_ao_cmd()` for the same reason
as above. (This was not needed in the upstream commit.) **
Note that the removed code in `usbduxsigma_ao_cmdtest()` checked that
`devpriv->ao_timer` did not end up less that 1, but that could not
happen due because `cmd->scan_begin_arg` or `cmd->convert_arg` had
already been range-checked.
Also note that we tested the `high_speed` variable in the old code, but
that is currently always 0 and means that we always use "scan" timing
(`cmd->scan_begin_src == TRIG_TIMER` and `cmd->convert_src == TRIG_NOW`)
and never "convert" (individual sample) timing (`cmd->scan_begin_src ==
TRIG_FOLLOW` and `cmd->convert_src == TRIG_TIMER`). The moved code
tests `cmd->convert_src` instead to decide whether "scan" or "convert"
timing is being used, although currently only "scan" timing is
supported.
Fixes: fb1ef622e7a3 ("staging: comedi: usbduxsigma: tidy up analog output command support")
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
---
drivers/staging/comedi/drivers/usbduxsigma.c | 41 ++++++++++++----------------
1 file changed, 17 insertions(+), 24 deletions(-)
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index c61a1b9d7cd8..580c1358eb84 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -950,10 +950,24 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
if (err)
return 3;
- /* Step 4: fix up any arguments */
+ return 0;
+}
+
+static int usbduxsigma_ao_cmd(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct usbduxsigma_private *devpriv = dev->private;
+ struct comedi_cmd *cmd = &s->async->cmd;
+ int ret;
+ int i;
+
+ down(&devpriv->sem);
+
+ /* set current channel of the running acquisition to zero */
+ s->async->cur_chan = 0;
/* we count in timer steps */
- if (high_speed) {
+ if (cmd->convert_src == TRIG_TIMER) {
/* timing of the conversion itself: every 125 us */
devpriv->ao_timer = cmd->convert_arg / 125000;
} else {
@@ -963,12 +977,9 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
*/
devpriv->ao_timer = cmd->scan_begin_arg / 1000000;
}
- if (devpriv->ao_timer < 1)
- err |= -EINVAL;
-
if (cmd->stop_src == TRIG_COUNT) {
/* not continuous, use counter */
- if (high_speed) {
+ if (cmd->convert_src == TRIG_TIMER) {
/* high speed also scans everything at once */
devpriv->ao_sample_count = cmd->stop_arg *
cmd->scan_end_arg;
@@ -987,24 +998,6 @@ static int usbduxsigma_ao_cmdtest(struct comedi_device *dev,
devpriv->ao_sample_count = 0;
}
- if (err)
- return 4;
-
- return 0;
-}
-
-static int usbduxsigma_ao_cmd(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- struct usbduxsigma_private *devpriv = dev->private;
- struct comedi_cmd *cmd = &s->async->cmd;
- int ret;
- int i;
-
- down(&devpriv->sem);
-
- /* set current channel of the running acquisition to zero */
- s->async->cur_chan = 0;
for (i = 0; i < cmd->chanlist_len; ++i)
devpriv->ao_chanlist[i] = CR_CHAN(cmd->chanlist[i]);
--
2.6.0
next prev parent reply other threads:[~2015-10-02 13:25 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-02 13:25 [PATCH 3.12 00/84] 3.12.49-stable review Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 01/84] PCI: Add dev_flags bit to access VPD through function 0 Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 02/84] PCI: Add VPD function 0 quirk for Intel Ethernet devices Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 03/84] staging: comedi: usbduxsigma: don't clobber ai_timer in command test Jiri Slaby
2015-10-02 13:24 ` Jiri Slaby [this message]
2015-10-02 13:24 ` [PATCH 3.12 05/84] staging: comedi: adl_pci7x3x: fix digital output on PCI-7230 Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 06/84] ext4: move check under lock scope to close a race Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 07/84] libfc: Fix fc_fcp_cleanup_each_cmd() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 08/84] regmap: regcache-rbtree: Clean new present bits on present bitmap resize Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 09/84] crypto: caam - fix memory corruption in ahash_final_ctx Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 10/84] arm64: KVM: Fix host crash when injecting a fault into a 32bit guest Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 11/84] DRM - radeon: Don't link train DisplayPort on HPD until we get the dpcd Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 12/84] drm/qxl: validate monitors config modes Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 13/84] iio: Add inverse unit conversion macros Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 14/84] iio: adis16480: Fix scale factors Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 15/84] clk: versatile: off by one in clk_sp810_timerclken_of_get() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 16/84] PCI: Fix TI816X class code quirk Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 17/84] USB: symbolserial: Use usb_get_serial_port_data Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 18/84] USB: ftdi_sio: Added custom PID for CustomWare products Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 19/84] usb: dwc3: ep0: Fix mem corruption on OUT transfers of more than 512 bytes Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 20/84] usb: host: ehci-sys: delete useless bus_to_hcd conversion Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 21/84] serial: 8250: don't bind to SMSC IrCC IR port Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 22/84] crypto: ghash-clmulni: specify context size for ghash async algorithm Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 23/84] HID: usbhid: Fix the check for HID_RESET_PENDING in hid_io_error Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 24/84] KVM: MMU: fix validation of mmio page fault Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 25/84] xtensa: fix threadptr reload on return to userspace Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 26/84] xtensa: fix kernel register spilling Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 27/84] devres: fix devres_get() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 28/84] auxdisplay: ks0108: fix refcount Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 29/84] of/address: Don't loop forever in of_find_matching_node_by_address() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 30/84] ARM: OMAP2+: DRA7: clockdomain: change l4per2_7xx_clkdm to SW_WKUP Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 31/84] drivercore: Fix unregistration path of platform devices Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 32/84] hpfs: update ctime and mtime on directory modification Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 33/84] tty/vt: don't set font mappings on vc not supporting this Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 34/84] unshare: Unsharing a thread does not require unsharing a vm Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 35/84] rtlwifi: rtl8192cu: Add new device ID Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 36/84] tg3: Fix temperature reporting Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 37/84] mac80211: enable assoc check for mesh interfaces Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 38/84] arm64: kconfig: Move LIST_POISON to a safe value Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 39/84] arm64: compat: fix vfp save/restore across signal handlers in big-endian Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 40/84] arm64: head.S: initialise mdcr_el2 in el2_setup Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 41/84] arm64: errata: add module build workaround for erratum #843419 Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 42/84] arm64: KVM: Disable virtual timer even if the guest is not using it Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 43/84] Input: evdev - do not report errors form flush() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 44/84] ALSA: hda - Enable headphone jack detect on old Fujitsu laptops Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 45/84] ALSA: hda - Use ALC880_FIXUP_FUJITSU for FSC Amilo M1437 Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 46/84] powerpc/mm: Fix pte_pagesize_index() crash on 4K w/64K hash Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 47/84] powerpc/rtas: Introduce rtas_get_sensor_fast() for IRQ handlers Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 48/84] powerpc/mm: Recompute hash value after a failed update Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 49/84] Add radeon suspend/resume quirk for HP Compaq dc5750 Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 50/84] x86/mm: Initialize pmd_idx in page_table_range_init_count() Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 51/84] rc-core: fix remove uevent generation Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 52/84] v4l: omap3isp: Fix sub-device power management code Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 53/84] Btrfs: check if previous transaction aborted to avoid fs corruption Jiri Slaby
2015-10-02 13:24 ` [PATCH 3.12 54/84] NFSv4: don't set SETATTR for O_RDONLY|O_EXCL Jiri Slaby
2015-10-02 13:25 ` [PATCH 3.12 55/84] NFS: nfs_set_pgio_error sometimes misses errors Jiri Slaby
2015-10-02 13:25 ` [PATCH 3.12 56/84] parisc: Filter out spurious interrupts in PA-RISC irq handler Jiri Slaby
2015-10-02 13:25 ` [PATCH 3.12 57/84] vmscan: fix increasing nr_isolated incurred by putback unevictable pages Jiri Slaby
2015-10-02 13:25 ` [PATCH 3.12 58/84] fs: if a coredump already exists, unlink and recreate with O_EXCL Jiri Slaby
2015-10-02 15:34 ` [PATCH 3.12 00/84] 3.12.49-stable review Shuah Khan
2015-10-06 8:40 ` Jiri Slaby
2015-10-02 16:09 ` Guenter Roeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=92ca2aaa4cc43fd8bb1cd018d7183a2d68352b2e.1443792303.git.jslaby@suse.cz \
--to=jslaby@suse.cz \
--cc=abbotti@mev.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®