lkml.org 
[lkml]   [2013]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] block:Remove extra condition in end of disk check
On 06/25/2013 04:21 AM, Tejun Heo wrote:
> On Mon, Jun 24, 2013 at 07:20:12PM +0530, Raghavendra K T wrote:
>>> @@ -1656,7 +1656,7 @@ static inline int bio_check_eod(struct bio *bio, unsigned int nr_sectors)
>>> if (maxsector) {
>>> sector_t sector = bio->bi_sector;
>>>
>>> - if (maxsector < nr_sectors || maxsector - nr_sectors < sector) {
>>> + if (maxsector - nr_sectors < sector) {
>
> If maxsector < nr_sectors, the subtraction will underflow making it a
> very large number and fail to detect the invalid condition, no?
>

Hi Tejun,
Thanks for the reply and explanation. You are right. underflow results
in invalid condition.

Considering maxsector and sectors are unsigned long, and nr_sector is
unsigned int, probably safer bet is
(max_sector < sector + nr_sector), but still it would leave scope for
overflow.

Thanks again,
Raghu.



\
 
 \ /
  Last update: 2013-06-25 07:21    [W:0.070 / U:0.792 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site