From: "Tobin C. Harding" <me@tobin.cc>
To: Ulf Hansson <ulf.hansson@linaro.org>
Cc: "Tobin C. Harding" <me@tobin.cc>,
Shawn Lin <shawn.lin@rock-chips.com>,
Linus Walleij <linus.walleij@linaro.org>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 0/2] mmc: core: null pointer dereference bug
Date: Wed, 15 Mar 2017 19:48:02 +1100 [thread overview]
Message-ID: <1489567684-22763-1-git-send-email-me@tobin.cc> (raw)
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(-)
--
2.7.4
next reply other threads:[~2017-03-15 8:48 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 8:48 Tobin C. Harding [this message]
2017-03-15 8:48 ` [PATCH 1/2] mmc: core: guard dereference of optional parameter Tobin C. Harding
2017-03-15 8:48 ` [PATCH 2/2] mmc: core: simplify return code Tobin C. Harding
2017-03-16 14:46 ` [PATCH 0/2] mmc: core: null pointer dereference bug Ulf Hansson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1489567684-22763-1-git-send-email-me@tobin.cc \
--to=me@tobin.cc \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mmc@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=ulf.hansson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox