From: Ian Abbott <abbotti@mev.co.uk> To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Ian Abbott <abbotti@mev.co.uk>, H Hartley Sweeten <hsweeten@visionengravers.com>, stable@vger.kernel.org Subject: [PATCH 02/14] staging: comedi: addi_apci_1500: Fix endian problem for command sample Date: Tue, 23 Feb 2021 14:30:43 +0000 [thread overview] Message-ID: <20210223143055.257402-3-abbotti@mev.co.uk> (raw) In-Reply-To: <20210223143055.257402-1-abbotti@mev.co.uk> The digital input subdevice supports Comedi asynchronous commands that read interrupt status information. This uses 16-bit Comedi samples (of which only the bottom 8 bits contain status information). However, the interrupt handler is calling `comedi_buf_write_samples()` with the address of a 32-bit variable `unsigned int status`. On a bigendian machine, this will copy 2 bytes from the wrong end of the variable. Fix it by changing the type of the variable to `unsigned short`. Fixes: a8c66b684efa ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions") Cc: <stable@vger.kernel.org> #4.0+ Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- .../staging/comedi/drivers/addi_apci_1500.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 11efb21555e3..b04c15dcfb57 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -208,7 +208,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) struct comedi_device *dev = d; struct apci1500_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned int status = 0; + unsigned short status = 0; unsigned int val; val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); @@ -238,14 +238,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) * * Mask Meaning * ---------- ------------------------------------------ - * 0x00000001 Event 1 has occurred - * 0x00000010 Event 2 has occurred - * 0x00000100 Counter/timer 1 has run down (not implemented) - * 0x00001000 Counter/timer 2 has run down (not implemented) - * 0x00010000 Counter 3 has run down (not implemented) - * 0x00100000 Watchdog has run down (not implemented) - * 0x01000000 Voltage error - * 0x10000000 Short-circuit error + * 0b00000001 Event 1 has occurred + * 0b00000010 Event 2 has occurred + * 0b00000100 Counter/timer 1 has run down (not implemented) + * 0b00001000 Counter/timer 2 has run down (not implemented) + * 0b00010000 Counter 3 has run down (not implemented) + * 0b00100000 Watchdog has run down (not implemented) + * 0b01000000 Voltage error + * 0b10000000 Short-circuit error */ comedi_buf_write_samples(s, &status, 1); comedi_handle_events(dev, s); -- 2.30.0
WARNING: multiple messages have this Message-ID (diff)
From: Ian Abbott <abbotti@mev.co.uk> To: devel@driverdev.osuosl.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Ian Abbott <abbotti@mev.co.uk>, stable@vger.kernel.org Subject: [PATCH 02/14] staging: comedi: addi_apci_1500: Fix endian problem for command sample Date: Tue, 23 Feb 2021 14:30:43 +0000 [thread overview] Message-ID: <20210223143055.257402-3-abbotti@mev.co.uk> (raw) In-Reply-To: <20210223143055.257402-1-abbotti@mev.co.uk> The digital input subdevice supports Comedi asynchronous commands that read interrupt status information. This uses 16-bit Comedi samples (of which only the bottom 8 bits contain status information). However, the interrupt handler is calling `comedi_buf_write_samples()` with the address of a 32-bit variable `unsigned int status`. On a bigendian machine, this will copy 2 bytes from the wrong end of the variable. Fix it by changing the type of the variable to `unsigned short`. Fixes: a8c66b684efa ("staging: comedi: addi_apci_1500: rewrite the subdevice support functions") Cc: <stable@vger.kernel.org> #4.0+ Signed-off-by: Ian Abbott <abbotti@mev.co.uk> --- .../staging/comedi/drivers/addi_apci_1500.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c index 11efb21555e3..b04c15dcfb57 100644 --- a/drivers/staging/comedi/drivers/addi_apci_1500.c +++ b/drivers/staging/comedi/drivers/addi_apci_1500.c @@ -208,7 +208,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) struct comedi_device *dev = d; struct apci1500_private *devpriv = dev->private; struct comedi_subdevice *s = dev->read_subdev; - unsigned int status = 0; + unsigned short status = 0; unsigned int val; val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); @@ -238,14 +238,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) * * Mask Meaning * ---------- ------------------------------------------ - * 0x00000001 Event 1 has occurred - * 0x00000010 Event 2 has occurred - * 0x00000100 Counter/timer 1 has run down (not implemented) - * 0x00001000 Counter/timer 2 has run down (not implemented) - * 0x00010000 Counter 3 has run down (not implemented) - * 0x00100000 Watchdog has run down (not implemented) - * 0x01000000 Voltage error - * 0x10000000 Short-circuit error + * 0b00000001 Event 1 has occurred + * 0b00000010 Event 2 has occurred + * 0b00000100 Counter/timer 1 has run down (not implemented) + * 0b00001000 Counter/timer 2 has run down (not implemented) + * 0b00010000 Counter 3 has run down (not implemented) + * 0b00100000 Watchdog has run down (not implemented) + * 0b01000000 Voltage error + * 0b10000000 Short-circuit error */ comedi_buf_write_samples(s, &status, 1); comedi_handle_events(dev, s); -- 2.30.0 _______________________________________________ devel mailing list devel@linuxdriverproject.org http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
next prev parent reply other threads:[~2021-02-23 14:42 UTC|newest] Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-02-23 14:30 [PATCH 00/14] staging: comedi: Fix some command data endian problems Ian Abbott 2021-02-23 14:30 ` [PATCH 01/14] staging: comedi: addi_apci_1032: Fix endian problem for COS sample Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` Ian Abbott [this message] 2021-02-23 14:30 ` [PATCH 02/14] staging: comedi: addi_apci_1500: Fix endian problem for command sample Ian Abbott 2021-02-23 14:30 ` [PATCH 03/14] staging: comedi: adv_pci1710: Fix endian problem for AI command data Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 04/14] staging: comedi: das6402: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 05/14] staging: comedi: das800: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 06/14] staging: comedi: dmm32at: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 07/14] staging: comedi: me4000: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 08/14] staging: comedi: pcl711: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 09/14] staging: comedi: pcl818: " Ian Abbott 2021-02-23 14:30 ` Ian Abbott 2021-02-23 14:30 ` [PATCH 10/14] staging: comedi: amplc_pc236_common: Use 16-bit 0 for interrupt data Ian Abbott 2021-02-23 14:30 ` [PATCH 11/14] staging: comedi: comedi_parport: " Ian Abbott 2021-02-23 14:30 ` [PATCH 12/14] staging: comedi: ni_6527: " Ian Abbott 2021-02-23 14:30 ` [PATCH 13/14] staging: comedi: ni_65xx: " Ian Abbott 2021-02-23 14:30 ` [PATCH 14/14] staging: comedi: pcl726: " Ian Abbott
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=20210223143055.257402-3-abbotti@mev.co.uk \ --to=abbotti@mev.co.uk \ --cc=devel@driverdev.osuosl.org \ --cc=gregkh@linuxfoundation.org \ --cc=hsweeten@visionengravers.com \ --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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.