From: Henry Chen <HenryC.Chen@mediatek.com>
To: Mark Brown <broonie@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
Sascha Hauer <kernel@pengutronix.de>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>,
<linux-mediatek@lists.infradead.org>, <eddie.huang@mediatek.com>
Subject: Re: [PATCH] regmap: Add function check before called format_val
Date: Wed, 22 Jul 2015 22:31:34 +0800 [thread overview]
Message-ID: <1437575494.30329.80.camel@mtksdaap41> (raw)
In-Reply-To: <20150721172550.GY11162@sirena.org.uk>
On Tue, 2015-07-21 at 18:25 +0100, Mark Brown wrote:
> On Tue, Jul 21, 2015 at 02:07:25PM +0800, Henry Chen wrote:
>
> > Then in driver rtc-mt6397.c, it used regmap_bulk_read() to get the time
> > of PMIC, and hit the null function of format_val(), because the
> > regmap_bus was null.
>
> > It skipped the initialization of format_val() because bus == null, but
> > called the format_val() at regmap_bulk_read() if bus == null.
>
> OK, so the issue here is that when we fall back to regmap_read() we may
> do so because we have reg_read() and reg_write() functions which in turn
> imply no formatting. The expectation here is that val must be an array
> of int. The code doesn't completely take that into account though and
> the user you're pointing at is assuming it's an array of 16 bit values
> which isn't totally unreasonable if it did specify val_bits (we don't
> check for that).
So, could I call regmap_bulk_read() on rtc-mt6307.c, should I need to
change it ?
>
> > Maybe it was not the good fix for this, but should be a problem need to
> > be reported, or should I need to give the regmap_bus on mtk_pmic_wrap.c?
>
> That file isn't in mainline...
oh...it's mtk-pmic-wrap.c, sorry about that.
>
> memcpy() is definitely not a safe way to move from an unsigned int to a
> u16 which is what your specific use case is trying to do. I'll need to
> do an audit of existing users (or someone else will!) to figure out what
> people are doing with .val_bits in drivers using reg_read() and
> reg_write() but I think what we should be doing here is probably
> providing appropriate conversion functions based on val_bits on init.
Ok, got it, memcpy() should not be used here anymore.
Thanks,
Henry
next prev parent reply other threads:[~2015-07-22 14:31 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-20 12:41 [PATCH] regmap: Add function check before called format_val Henry Chen
2015-07-20 15:02 ` Mark Brown
2015-07-21 6:07 ` Henry Chen
2015-07-21 17:25 ` Mark Brown
2015-07-22 14:31 ` Henry Chen [this message]
2015-07-22 17:00 ` Mark Brown
2015-08-12 14:20 ` Daniel Kurtz
2015-08-13 15:25 ` Henry Chen
2015-08-14 17:56 ` Mark Brown
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=1437575494.30329.80.camel@mtksdaap41 \
--to=henryc.chen@mediatek.com \
--cc=broonie@kernel.org \
--cc=eddie.huang@mediatek.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.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;
as well as URLs for NNTP newsgroup(s).