linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: srinivas.kandagatla@linaro.org (Srinivas Kandagatla)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] regmap: Add range check in _regmap_raw_read()
Date: Thu, 19 Feb 2015 11:04:39 +0000	[thread overview]
Message-ID: <54E5C347.9070105@linaro.org> (raw)
In-Reply-To: <20150219102750.GC3198@finisterre.sirena.org.uk>



On 19/02/15 10:27, Mark Brown wrote:
> On Thu, Feb 19, 2015 at 08:40:39AM +0000, Srinivas Kandagatla wrote:
>
>> +	/* Check for readable registers before we start */
>> +	for (i = 0; i < count; i++)
>> +		if (!regmap_readable(map, reg + (i * map->reg_stride)))
>> +			return -EINVAL;
>
> That's starting to look pretty expensive especially if what we're
> looking for is just max_register really...  This is one of the reasons
Yes, I totally agree, this call would be expensive.

Initially I had some thing like this, and it works for me.

+       if (map->max_register &&
+                       (reg > map->max_register ||
+                       ((reg + (count - 1) * map->reg_stride)  > 
map->max_register)))
+               return -EINVAL;


> we're not religious about checking for readability everywhere, and
> obviously even if we avoid triggering this particular thing we still
> have to cope with both the caller and devices that didn't specify
> readability.  A cheaper check for just max_register would be less
> concerning but it feels like we're trying to paper over a symptom with
> this rather than fix a problem.
Yes, just checking max_register would solve the issue for me, I think I 
over done the patch.. I will resend with just max_register check.


>

  reply	other threads:[~2015-02-19 11:04 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-19  8:39 [PATCH 0/2] regmap: fix range checks in _regmap_raw_read/write() Srinivas Kandagatla
2015-02-19  8:40 ` [PATCH 1/2] regmap: Add range check in _regmap_raw_read() Srinivas Kandagatla
2015-02-19 10:27   ` Mark Brown
2015-02-19 11:04     ` Srinivas Kandagatla [this message]
2015-02-19 12:21       ` Mark Brown
2015-02-19 13:02         ` Srinivas Kandagatla
2015-02-24  8:55           ` Mark Brown
2015-02-24  9:12             ` Srinivas Kandagatla
2015-02-19  8:40 ` [PATCH 2/2] regmap: Add range check in _regmap_raw_write() Srinivas Kandagatla
2015-02-19 10:31   ` Mark Brown
2015-02-19 11:11     ` Srinivas Kandagatla
2015-02-19 11:55       ` 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=54E5C347.9070105@linaro.org \
    --to=srinivas.kandagatla@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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;
as well as URLs for NNTP newsgroup(s).