• A
    rbd: check for overflow in rbd_get_num_segments() · df111be6
    Alex Elder 提交于
    It is possible in rbd_get_num_segments() for an overflow to occur
    when adding the offset and length.  This is easily avoided.
    
    Since the function returns an int and the one caller is already
    prepared to handle errors, have it return -ERANGE if overflow would
    occur.
    
    The overflow check would not work if a zero-length request was
    being tested, so short-circuit that case, returning 0 for the
    number of segments required.  (This condition might be avoided
    elsewhere already, I don't know.)
    
    Have the caller end the request if either an error or 0 is returned.
    The returned value is passed to __blk_end_request_all(), meaning
    a 0 length request is not treated an error.
    Signed-off-by: NAlex Elder <elder@inktank.com>
    Reviewed-by: NYehuda Sadeh <yehuda@inktank.com>
    df111be6
rbd.c 63.2 KB