diff options
author | Ian Abbott <abbotti@mev.co.uk> | 2014-01-21 12:39:05 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 14:08:46 -0500 |
commit | 791771e4e0587652e193ac8920e14911045a1dc8 (patch) | |
tree | f57532192bd48af8104a3afa296f5a8450f3998f /drivers/staging | |
parent | f1ffdfcc52744ed264041741020364cfbad9c0de (diff) |
staging: comedi: usbduxsigma: fix unaligned dereferences
There are a couple of dereferences such as `*(uint32_t
*)(devpriv->insn_buf + 1)` that are unaligned as `devpriv->insn_buf` is
of type `uint8_t *`. This works on x86 architecture but may not be
supported on other architectures. Call `get_unalign()` to perform the
unaligned dereferences.
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Cc: Bernd Porr <mail@berndporr.me.uk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging')
-rw-r--r-- | drivers/staging/comedi/drivers/usbduxsigma.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index 3beeb1254152..88c60b6020c4 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c | |||
@@ -48,6 +48,7 @@ | |||
48 | #include <linux/usb.h> | 48 | #include <linux/usb.h> |
49 | #include <linux/fcntl.h> | 49 | #include <linux/fcntl.h> |
50 | #include <linux/compiler.h> | 50 | #include <linux/compiler.h> |
51 | #include <asm/unaligned.h> | ||
51 | 52 | ||
52 | #include "comedi_fc.h" | 53 | #include "comedi_fc.h" |
53 | #include "../comedidev.h" | 54 | #include "../comedidev.h" |
@@ -792,7 +793,8 @@ static int usbduxsigma_ai_insn_read(struct comedi_device *dev, | |||
792 | } | 793 | } |
793 | 794 | ||
794 | /* 32 bits big endian from the A/D converter */ | 795 | /* 32 bits big endian from the A/D converter */ |
795 | val = be32_to_cpu(*((uint32_t *)((devpriv->insn_buf) + 1))); | 796 | val = be32_to_cpu(get_unaligned((uint32_t |
797 | *)(devpriv->insn_buf + 1))); | ||
796 | val &= 0x00ffffff; /* strip status byte */ | 798 | val &= 0x00ffffff; /* strip status byte */ |
797 | val ^= 0x00800000; /* convert to unsigned */ | 799 | val ^= 0x00800000; /* convert to unsigned */ |
798 | 800 | ||
@@ -1357,7 +1359,7 @@ static int usbduxsigma_getstatusinfo(struct comedi_device *dev, int chan) | |||
1357 | return ret; | 1359 | return ret; |
1358 | 1360 | ||
1359 | /* 32 bits big endian from the A/D converter */ | 1361 | /* 32 bits big endian from the A/D converter */ |
1360 | val = be32_to_cpu(*((uint32_t *)((devpriv->insn_buf)+1))); | 1362 | val = be32_to_cpu(get_unaligned((uint32_t *)(devpriv->insn_buf + 1))); |
1361 | val &= 0x00ffffff; /* strip status byte */ | 1363 | val &= 0x00ffffff; /* strip status byte */ |
1362 | val ^= 0x00800000; /* convert to unsigned */ | 1364 | val ^= 0x00800000; /* convert to unsigned */ |
1363 | 1365 | ||