From: Grant Likely <grant.likely@linaro.org>
To: Lee Jones <lee.jones@linaro.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, wsa@the-dreams.de
Cc: linus.walleij@linaro.org, linux-i2c@vger.kernel.org,
Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id()
Date: Mon, 02 Jun 2014 17:07:15 +0100 [thread overview]
Message-ID: <20140602160715.5E90FC40476@trevor.secretlab.ca> (raw)
In-Reply-To: <1401716463-23457-3-git-send-email-lee.jones@linaro.org>
On Mon, 2 Jun 2014 14:41:02 +0100, Lee Jones <lee.jones@linaro.org> wrote:
> Here we're providing dereference protection for i2c_match_id(), which
> saves us having to do it each time it's called. We're also stripping
> out the (now) needless check in i2c_device_match(). This patch paves
> the way for other, similar code trimming.
>
> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Seems reasonable.
Acked-by: Grant Likely <grant.likely@linaro.org>
> ---
> drivers/i2c/i2c-core.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 2e47641..d0c7180 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -83,6 +83,9 @@ void i2c_transfer_trace_unreg(void)
> static const struct i2c_device_id *i2c_match_id(const struct i2c_device_id *id,
> const struct i2c_client *client)
> {
> + if (!id)
> + return NULL;
> +
> while (id->name[0]) {
> if (strcmp(client->name, id->name) == 0)
> return id;
> @@ -108,9 +111,10 @@ static int i2c_device_match(struct device *dev, struct device_driver *drv)
> return 1;
>
> driver = to_i2c_driver(drv);
> - /* match on an id table if there is one */
> - if (driver->id_table)
> - return i2c_match_id(driver->id_table, client) != NULL;
> +
> + /* Finally an I2C match */
> + if (i2c_match_id(driver->id_table, client))
> + return 1;
>
> return 0;
> }
> --
> 1.8.3.2
>
next prev parent reply other threads:[~2014-06-02 16:07 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-02 13:41 [PATCH 0/3] i2c: Relax requirement for I2C Device ID tables Lee Jones
2014-06-02 13:41 ` [PATCH 1/3] i2c: Provide 'device type' to 'OF device node' look-up Lee Jones
2014-06-02 13:57 ` Lee Jones
2014-06-02 16:06 ` Grant Likely
2014-06-02 16:19 ` Lee Jones
2014-06-02 13:41 ` [PATCH 2/3] i2c: Add pointer dereference protection to i2c_match_id() Lee Jones
2014-06-02 16:07 ` Grant Likely [this message]
2014-06-02 13:41 ` [PATCH 3/3] i2c: Make I2C ID tables non-mandatory for DT'ed and/or ACPI'ed devices Lee Jones
2014-06-02 14:34 ` One Thousand Gnomes
2014-06-03 8:11 ` Lee Jones
2014-06-02 16:08 ` Grant Likely
2014-06-03 8:11 ` Lee Jones
2014-06-03 9:18 ` Grant Likely
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=20140602160715.5E90FC40476@trevor.secretlab.ca \
--to=grant.likely@linaro.org \
--cc=lee.jones@linaro.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-i2c@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wsa@the-dreams.de \
/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
all inboxes | Powered by JetHome®