Staging: rtl8188eu: Use put_unaligned_le32

Dan Carpenter dan.carpenter at oracle.com
Thu Nov 6 13:29:51 UTC 2014


Hello Vaishali Thakkar,

The patch 2b365fa9d926: "Staging: rtl8188eu: Use put_unaligned_le32"
from Oct 31, 2014, leads to the following static checker warning:

	include/linux/unaligned/access_ok.h:44 put_unaligned_le32()
	warn: potential memory corrupting cast 4 vs 3 bytes

drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c
   146  u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask)
   147  {
   148          u8 buf[3];
   149          u8 res = _SUCCESS;
   150          struct hal_data_8188e *haldata = GET_HAL_DATA(adapt);
   151  
   152          if (haldata->fw_ractrl) {
   153  
   154                  memset(buf, 0, 3);
                        ^^^^^^^^^^^^^^^^^
This memset doesn't make sense.  We clear "buf" on the next line.

   155                  put_unaligned_le32(mask, buf);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This corrupts "res".  I think we could just make "buf" larger and the
code would work?

   156  
   157                  FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf);
   158          } else {
   159                  DBG_88E("==>%s fw dont support RA\n", __func__);
   160                  res = _FAIL;
   161          }
   162  
   163  
   164          return res;
   165  }

regards,
dan carpenter


More information about the devel mailing list