From: Henry Ptasinski Date: Mon, 15 Aug 2011 13:34:21 +0000 (+0200) Subject: staging: brcm80211: fix off-by-one error in swap functions X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ac98a56fac0cafb56d900154ac4569a959011c0;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git staging: brcm80211: fix off-by-one error in swap functions The original implementation iterated over the data in buf+1 through buf+size, whereas it should have been over the data in buf through buf+size-1. Tested on Mac G5 PPC and BCM63281. Signed-off-by: Henry Ptasinski Reviewed-by: Arend van Spriel Reviewed-by: Roland Vossen Tested-by: Jonas Gorski Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/brcm80211/brcmsmac/srom.c b/drivers/staging/brcm80211/brcmsmac/srom.c index 060f06fc1440..7a17f598e499 100644 --- a/drivers/staging/brcm80211/brcmsmac/srom.c +++ b/drivers/staging/brcm80211/brcmsmac/srom.c @@ -880,13 +880,15 @@ int srom_var_init(struct si_pub *sih, void *curmap, char **vars, uint *count) static inline void ltoh16_buf(u16 *buf, unsigned int size) { - for (size /= 2; size; size--) + size /= 2; + while (size--) *(buf + size) = le16_to_cpu(*(buf + size)); } static inline void htol16_buf(u16 *buf, unsigned int size) { - for (size /= 2; size; size--) + size /= 2; + while (size--) *(buf + size) = cpu_to_le16(*(buf + size)); }