Skip to content

Commit

Permalink
staging: brcm80211: bugfix for exception on Sparc platforms
Browse files Browse the repository at this point in the history
Problem would pop up during driver load on a Sun Fire V120 and manifested
itself as an exception. This was caused by int* pointers provided to memcpy()
that were not aligned on an int boundary. The pointer type provided to
memcpy() is used by the compiler for optimization purposes. Fix was to cast
the int* pointers to void* pointers.

Bernhard R. Link and David S. Miller provided valuable feedback, thanks gents.

Reviewed-by: Arend van Spriel <arend@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Roland Vossen authored and Greg Kroah-Hartman committed Aug 23, 2011
1 parent 183eeb9 commit 49d468f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/staging/brcm80211/brcmsmac/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6111,9 +6111,12 @@ _brcms_c_ioctl(struct brcms_c_info *wlc, int cmd, void *arg, int len,
/* default argument is generic integer */
pval = arg ? (int *)arg : NULL;

/* This will prevent the misaligned access */
/*
* This will prevent misaligned access. The (void *) cast prevents a
* memcpy alignment issue on e.g. Sparc64 platforms.
*/
if (pval && (u32) len >= sizeof(val))
memcpy(&val, pval, sizeof(val));
memcpy((void *)&val, (void *)pval, sizeof(val));
else
val = 0;

Expand Down

0 comments on commit 49d468f

Please sign in to comment.