Skip to content

staging: r8188eu: avoid uninit value bugs

Pavel Skripkin linux-staging lkml oe-kbuild-all 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest6 patches 49 repliesIn review
  2. v2 RFC6 patches 24 repliesSuperseded
  3. v1 RFC3 patches 25 repliesSuperseded

Changes in v3 from the cover letter

1. Fixed OOPS in usb_read32(), caused by writing to u32 **
2. Fixed style in rtw_read32, rtw_read16 and rtw_read8 (Suggested by Dan)
3. Added error hanling when usb_control_msg() returns ret != len
NOTE: Dan suggested to add this to usbctrl_vendorreq(), but there is pending series, which will get rid of usb_control_msg(), so (res != len) check can be removed, when Fabio's series will go in
4. Removed RFC tag

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6staging: r8188eu: remove {read,write}_macregdrivers/staging/r8188eu/core/rtw_mp.c drivers/staging/r8188eu/include/rtw_mp.h+0 -412 replies
2/6staging: r8188eu: add helper macro for printing registersdrivers/staging/r8188eu/include/rtw_debug.h+13 -01 reply
3/6staging: r8188eu: add error handling of rtw_read8drivers/staging/r8188eu/core/rtw_debug.c drivers/staging/r8188eu/core/rtw_efuse.c drivers/staging/r8188eu/core/rtw_io.c +17 more+568 -15818 replies
4/6staging: r8188eu: add error handling of rtw_read16drivers/staging/r8188eu/core/rtw_debug.c drivers/staging/r8188eu/core/rtw_io.c drivers/staging/r8188eu/core/rtw_mp_ioctl.c +8 more+115 -3815 replies
5/6staging: r8188eu: add error handling of rtw_read32drivers/staging/r8188eu/core/rtw_debug.c drivers/staging/r8188eu/core/rtw_efuse.c drivers/staging/r8188eu/core/rtw_io.c +15 more+357 -10510 replies
6/6staging: r8188eu: make ReadEFuse return an intdrivers/staging/r8188eu/core/rtw_efuse.c drivers/staging/r8188eu/hal/hal_intf.c drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +5 more+96 -530 replies

Reviews trailers per patch

None of the 6 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchFabio M. De Francesco
SeriesA-b
1/6
2/6
3/6
4/6
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] staging: r8188eu: avoid uninit value bugs

Hi, Greg, Larry and Phillip!

I noticed, that new staging driver was added like 3 weeks ago and I decided to look at the code, because drivers in staging directory are always buggy.

The first thing I noticed is *no one* was checking read operations result, but it can fail and driver may start writing random stack values into registers. It can cause driver misbehavior or device misbehavior.

To avoid this type of bugs, i've changed rtw_read* API. Now all rtw_read funtions return an error, when something went wrong with usb transfer.

It helps callers to break/return earlier and don't write random values to registers or to rely on random values.

v2 -> v3:
1. Fixed OOPS in usb_read32(), caused by writing to u32 **
2. Fixed style in rtw_read32, rtw_read16 and rtw_read8 (Suggested by Dan)
3. Added error hanling when usb_control_msg() returns ret != len
NOTE: Dan suggested to add this to usbctrl_vendorreq(), but there is pending series, which will get rid of usb_control_msg(), so (res != len) check can be removed, when Fabio's series will go in
4. Removed RFC tag

v1 -> v2:
1. Make rtw_read*() return an error instead of initializing pointer to error
2. Split one huge patch to smaller ones for each rtw_read{8,16,32} function changes
3. Add new macro for printing register values (It helps to not copy-paste error handling)
4. Removed {read,write}_macreg (Suggested by Phillip)
5. Rebased on top of staging-next
6. Cleaned checkpatch errors and warnings

Phillip has tested fixed v2 version, AFAIU

Pavel Skripkin (6):
staging: r8188eu: remove {read,write}_macreg
staging: r8188eu: add helper macro for printing registers
staging: r8188eu: add error handling of rtw_read8
staging: r8188eu: add error handling of rtw_read16
staging: r8188eu: add error handling of rtw_read32
staging: r8188eu: make ReadEFuse return an int

 drivers/staging/r8188eu/core/rtw_debug.c      |  79 +++-
 drivers/staging/r8188eu/core/rtw_efuse.c      | 125 +++--
 drivers/staging/r8188eu/core/rtw_io.c         |  27 +-
 drivers/staging/r8188eu/core/rtw_mp.c         |  70 ++-
 drivers/staging/r8188eu/core/rtw_mp_ioctl.c   |  13 +-
 drivers/staging/r8188eu/core/rtw_pwrctrl.c    |   5 +-
 drivers/staging/r8188eu/core/rtw_sreset.c     |   9 +-
 .../r8188eu/hal/Hal8188ERateAdaptive.c        |   8 +-
 drivers/staging/r8188eu/hal/HalPhyRf_8188e.c  |  21 +-
 drivers/staging/r8188eu/hal/HalPwrSeqCmd.c    |   9 +-
 drivers/staging/r8188eu/hal/hal_com.c         |  23 +-
 drivers/staging/r8188eu/hal/hal_intf.c        |   6 +-
 drivers/staging/r8188eu/hal/odm_interface.c   |  12 +-
 drivers/staging/r8188eu/hal/rtl8188e_cmd.c    |  33 +-
 drivers/staging/r8188eu/hal/rtl8188e_dm.c     |   6 +-
 .../staging/r8188eu/hal/rtl8188e_hal_init.c   | 285 +++++++++---
 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c |  27 +-
 drivers/staging/r8188eu/hal/rtl8188e_sreset.c |  22 +-
 drivers/staging/r8188eu/hal/rtl8188eu_led.c   |  18 +-
 drivers/staging/r8188eu/hal/usb_halinit.c     | 439 +++++++++++++++---
 drivers/staging/r8188eu/hal/usb_ops_linux.c   |  62 ++-
 drivers/staging/r8188eu/include/hal_intf.h    |   6 +-
 .../staging/r8188eu/include/odm_interface.h   |   6 +-
 .../staging/r8188eu/include/rtl8188e_hal.h    |   2 +-
 drivers/staging/r8188eu/include/rtw_debug.h   |  13 +
 drivers/staging/r8188eu/include/rtw_efuse.h   |   4 +-
 drivers/staging/r8188eu/include/rtw_io.h      |  18 +-
 drivers/staging/r8188eu/include/rtw_mp.h      |   2 -
 drivers/staging/r8188eu/os_dep/ioctl_linux.c  | 179 +++++--
 drivers/staging/r8188eu/os_dep/usb_intf.c     |   3 +-
 30 files changed, 1143 insertions(+), 389 deletions(-)
Signature · 1 line
2.32.0