[PATCH] Fix an inproper alignment accessing in irda protocol stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

For "struct irda_device_info" in irda.h:
struct irda_device_info {
	__u32       saddr;    /* Address of local interface */
	__u32       daddr;    /* Address of remote device */
	char        info[22]; /* Description */
	__u8        charset;  /* Charset used for description */
	__u8        hints[2]; /* Hint bits */
};
  The "hints" member aligns at the third byte of a word, an odd
address. So if we visit "hints" as a short in irlmp.c:

   u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;

 will cause alignment problem on some machines. Architectures with
strict alignment rules do not allow 16-bit read on an odd address.

Signed-off-by: Luke Yang <[email protected]>

irlmp.c |    3 ++-
1 files changed, 2 insertions(+), 1 deletion(-)

--- net/irda/irlmp.c.old        2006-06-08 14:49:20.000000000 +0800
+++ net/irda/irlmp.c    2006-06-08 14:54:29.000000000 +0800
@@ -849,7 +849,8 @@
       }

       /* Construct new discovery info to be used by IrLAP, */
-       u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
+       irlmp->discovery_cmd.data.hints[0] = irlmp->hints.word & 0xff;
+       irlmp->discovery_cmd.data.hints[1] = (irlmp->hints.word & 0xff00) >> 8;

       /*
        *  Set character set for device name (we use ASCII), and

--
Best regards,
Luke Yang
[email protected]
--- net/irda/irlmp.c.old	2006-06-08 14:49:20.000000000 +0800
+++ net/irda/irlmp.c	2006-06-08 14:54:29.000000000 +0800
@@ -849,7 +849,8 @@
 	}
 
 	/* Construct new discovery info to be used by IrLAP, */
-	u16ho(irlmp->discovery_cmd.data.hints) = irlmp->hints.word;
+	irlmp->discovery_cmd.data.hints[0] = irlmp->hints.word & 0xff;
+	irlmp->discovery_cmd.data.hints[1] = (irlmp->hints.word & 0xff00) >> 8;
 
 	/*
 	 *  Set character set for device name (we use ASCII), and

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux