lkml.org 
[lkml]   [2015]   [Feb]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 2/2] regmap: Add range check in _regmap_raw_write()
On Thu, Feb 19, 2015 at 08:40:55AM +0000, Srinivas Kandagatla wrote:
> regmap_bulk_write() ends up using the path that invokes _regmap_raw_write(),
> however _regmap_raw_write() never checks if the registers that are accessed
> are actually within the accessible range. This results in kernel crashes when
> trying to access registers beyond max_registers.
>
> This patch just adds check before accessing the register range.

> /* Check for unwritable registers before we start */
> - if (map->writeable_reg)
> - for (i = 0; i < val_len / map->format.val_bytes; i++)
> - if (!map->writeable_reg(map->dev,
> - reg + (i * map->reg_stride)))
> - return -EINVAL;
> + for (i = 0; i < count; i++)
> + if (!regmap_writeable(map, reg + (i * map->reg_stride)))
> + return -EINVAL;

Your changelog doesn't correspond to what the code is actually doing
here... what you're actually doing here is replacing an open coding of
regmap_writeable() with calls to the function.

The same papering over the cracks concerns do apply here as well, it's
not immediately obvious that this is a good fix for the issue you
describe.
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2015-02-19 11:41    [W:0.138 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site