Skip to content

mmc: core: null pointer dereference bug

Tobin C. Harding linux-mmc lkml 1 version Applied

Status from this message: Thanks, applied for next!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/2mmc: core: guard dereference of optional parameterdrivers/mmc/core/sdio_io.c+8 -40 replies
2/2mmc: core: simplify return codedrivers/mmc/core/sdio_io.c+13 -290 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] mmc: core: null pointer dereference bug

Various functions take as parameter an optional pointer. Pointer should be guarded with non-NULL check before dereferencing.

While fixing this bug it was found that the file contains multiple functions doing variations on the same thing, sdio_readb(), sdio_writeb(), sdio_readw(), sdio_writew() etc. Although the functions have very similar logic the code is laid out in a variety of ways. This makes it overly complicated to read. There is a already a nice clean chunk of code, if we use this format for all instances then we will have cleaned up the code, reduced the line count and lessened the cognitive load required while reading.

Patch 01 adds non-NULL check before dereference of pointer.

Patch 02 cleans up the return code to be simple and uniform.

Code has not been tested. sdio_io.c with patches applied has been checked with checkpatch, Sparse, and Smatch. Each patch has been applied and built on x86_64 and PowerPC

Tobin C. Harding (2):
mmc: core: guard dereference of optional parameter
mmc: core: simplify return code

 drivers/mmc/core/sdio_io.c | 54 ++++++++++++++++++----------------------------
 1 file changed, 21 insertions(+), 33 deletions(-)
Signature · 1 line
2.7.4