From: Ilya Yanok <yanok@emcraft.com>
To: Ilya Yanok <yanok@emcraft.com>
Cc: linux-kernel@vger.kernel.org, Samuel Ortiz <sameo@linux.intel.com>
Subject: Re: [PATCH] twl-core: fix oops while calling twl_i2c_* for unbound driver
Date: Wed, 09 Nov 2011 04:24:04 +0400 [thread overview]
Message-ID: <4EB9C824.5070504@emcraft.com> (raw)
In-Reply-To: <1312232428-31001-1-git-send-email-yanok@emcraft.com>
Hi,
this is still unfixed. twl_i2c_{read,write} are exported and can be
called before driver initialization so we have to check it before
dereferencing twl_map.
Regards, Ilya.
02.08.2011 1:00, Ilya Yanok wrote:
> Check inuse variable before trying to access twl_map to prevent
> dereferencing of uninitialized variable.
>
> Signed-off-by: Ilya Yanok<yanok@emcraft.com>
> ---
> drivers/mfd/twl-core.c | 16 ++++++++--------
> 1 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c
> index 01ecfee..c7bc222 100644
> --- a/drivers/mfd/twl-core.c
> +++ b/drivers/mfd/twl-core.c
> @@ -362,13 +362,13 @@ int twl_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
> - sid = twl_map[mod_no].sid;
> - twl =&twl_modules[sid];
> -
> if (unlikely(!inuse)) {
> - pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> + sid = twl_map[mod_no].sid;
> + twl =&twl_modules[sid];
> +
> mutex_lock(&twl->xfer_lock);
> /*
> * [MSG1]: fill the register address data
> @@ -419,13 +419,13 @@ int twl_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
> pr_err("%s: invalid module number %d\n", DRIVER_NAME, mod_no);
> return -EPERM;
> }
> - sid = twl_map[mod_no].sid;
> - twl =&twl_modules[sid];
> -
> if (unlikely(!inuse)) {
> - pr_err("%s: client %d is not initialized\n", DRIVER_NAME, sid);
> + pr_err("%s: not initialized\n", DRIVER_NAME);
> return -EPERM;
> }
> + sid = twl_map[mod_no].sid;
> + twl =&twl_modules[sid];
> +
> mutex_lock(&twl->xfer_lock);
> /* [MSG1] fill the register address data */
> msg =&twl->xfer_msg[0];
next prev parent reply other threads:[~2011-11-09 0:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-01 21:00 [PATCH] twl-core: fix oops while calling twl_i2c_* for unbound driver Ilya Yanok
2011-11-09 0:24 ` Ilya Yanok [this message]
2011-11-14 0:26 ` Samuel Ortiz
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=4EB9C824.5070504@emcraft.com \
--to=yanok@emcraft.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.