[Skiboot] [RFC,PATCH 1/3] core/flash: Add flash API
Jeremy Kerr
jk at ozlabs.org
Mon Feb 9 12:57:04 AEDT 2015
Hi Joel,
> On Fri, Feb 6, 2015 at 9:39 PM, Jeremy Kerr <jk at ozlabs.org> wrote:
>> diff --git a/core/flash.c b/core/flash.c
>> new file mode 100644
>> index 0000000..4a4198d
>> --- /dev/null
>> +++ b/core/flash.c
>
>> +static int64_t opal_flash_op(uint64_t id, uint64_t offset, uint64_t buf,
>> + uint64_t size, uint64_t token, enum flash_op op)
>> +{
...
>> +
>> + if (size >= flash->size || offset >= flash->size
>> + || offset + size >= flash->size) {
>
> Do we want to check for overflow here?
For this to overflow, we'd need:
offset + size > 0xffffffffffffffff
but we've already tested that both size and offset are less than
flash->size, which is a u32, so has a maximum of 0xffffffff. The largest
that offset + size can be is 0x1fffffffe, which won't overflow the u64.
Cheers,
Jeremy
More information about the Skiboot
mailing list