linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bluetooth: fix unaligned access to l2cap conf data
@ 2010-10-16 22:29 Mike Frysinger
  2010-10-18 11:51 ` Marcel Holtmann
  2010-10-18 18:17 ` Harvey Harrison
  0 siblings, 2 replies; 9+ messages in thread
From: Mike Frysinger @ 2010-10-16 22:29 UTC (permalink / raw)
  To: linux-bluetooth, Marcel Holtmann
  Cc: uclinux-dist-devel, linux-kernel, Andrew Morton, steven miao

From: steven miao <realmz6@gmail.com>

In function l2cap_get_conf_opt() and l2cap_add_conf_opt() the address of
opt->val sometimes is not at the edge of 2-bytes/4-bytes, so 2-bytes/4 bytes
access will cause data misalignment exeception.  Use get_unaligned_le16/32
and put_unaligned_le16/32 function to avoid data misalignment execption.

Signed-off-by: steven miao <realmz6@gmail.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
was posted a month ago with no feedback ...

 net/bluetooth/l2cap.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index 0b54b7d..65bcdc1 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -2401,11 +2401,11 @@ static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned
 		break;
 
 	case 2:
-		*val = __le16_to_cpu(*((__le16 *) opt->val));
+		*val = get_unaligned_le16(opt->val);
 		break;
 
 	case 4:
-		*val = __le32_to_cpu(*((__le32 *) opt->val));
+		*val = get_unaligned_le32(opt->val);
 		break;
 
 	default:
@@ -2432,11 +2432,11 @@ static void l2cap_add_conf_opt(void **ptr, u8 type, u8 len, unsigned long val)
 		break;
 
 	case 2:
-		*((__le16 *) opt->val) = cpu_to_le16(val);
+		put_unaligned_le16(cpu_to_le16(val), opt->val);
 		break;
 
 	case 4:
-		*((__le32 *) opt->val) = cpu_to_le32(val);
+		put_unaligned_le32(cpu_to_le32(val), opt->val);
 		break;
 
 	default:
-- 
1.7.3.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread
[parent not found: <1283149112-22164-1-git-send-email-realmz6@gmail.com>]

end of thread, other threads:[~2010-10-18 19:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-16 22:29 [PATCH] bluetooth: fix unaligned access to l2cap conf data Mike Frysinger
2010-10-18 11:51 ` Marcel Holtmann
2010-10-18 15:59   ` Gustavo F. Padovan
2010-10-18 18:17 ` Harvey Harrison
2010-10-18 16:32   ` Gustavo F. Padovan
2010-10-18 19:10     ` Mike Frysinger
2010-10-18 19:12       ` Gustavo F. Padovan
2010-10-18 19:39         ` Mike Frysinger
     [not found] <1283149112-22164-1-git-send-email-realmz6@gmail.com>
2010-09-17  3:13 ` [PATCH] Bluetooth: Fix " real mz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).