From: Lee Jones <lee.jones@linaro.org>
To: Himangi Saraogi <himangi774@gmail.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
linux-kernel@vger.kernel.org, Julia Lawall <julia.lawall@lip6.fr>
Subject: Re: [PATCH] mfd: menelaus: remove null pointer dereference
Date: Thu, 21 Aug 2014 09:37:16 +0100 [thread overview]
Message-ID: <20140821083716.GU4266@lee--X1> (raw)
In-Reply-To: <20140809164027.GA20561@himangi-Dell>
On Sat, 09 Aug 2014, Himangi Saraogi wrote:
> If vtg is NULL, it is not possible to access its mode_reg field. At all
> sites where the static function menelaus_set_voltage is called, the first
> argument is the address of a structure defined in the file. So, the null
> test is unnecessary and is removed. Also, a label is done away with.
>
> This problem was found using the following Coccinelle semantic match:
>
> // <smpl>
> @@
> expression E, E1;
> identifier f;
> statement S1,S2,S3;
> @@
>
> * if (E == NULL)
> {
> ... when != if (E == NULL) S1 else S2
> when != E = E1
> * E->f
> ... when any
> return ...;
> }
> else S3
> // </smpl>
>
> Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
> Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> Not compile tested.
> drivers/mfd/menelaus.c | 3 ---
> 1 file changed, 3 deletions(-)
Applied, thanks.
> diff --git a/drivers/mfd/menelaus.c b/drivers/mfd/menelaus.c
> index 5e2667a..18ff56f 100644
> --- a/drivers/mfd/menelaus.c
> +++ b/drivers/mfd/menelaus.c
> @@ -466,8 +466,6 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV,
> struct i2c_client *c = the_menelaus->client;
>
> mutex_lock(&the_menelaus->lock);
> - if (!vtg)
> - goto set_voltage;
>
> ret = menelaus_read_reg(vtg->vtg_reg);
> if (ret < 0)
> @@ -482,7 +480,6 @@ static int menelaus_set_voltage(const struct menelaus_vtg *vtg, int mV,
> ret = menelaus_write_reg(vtg->vtg_reg, val);
> if (ret < 0)
> goto out;
> -set_voltage:
> ret = menelaus_write_reg(vtg->mode_reg, mode);
> out:
> mutex_unlock(&the_menelaus->lock);
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
prev parent reply other threads:[~2014-08-21 8:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-09 16:40 [PATCH] mfd: menelaus: remove null pointer dereference Himangi Saraogi
2014-08-21 8:37 ` Lee Jones [this message]
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=20140821083716.GU4266@lee--X1 \
--to=lee.jones@linaro.org \
--cc=himangi774@gmail.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@linux.intel.com \
/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