mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
block: Fix overrun in lcm() and move it to lib
lcm() was defined to take integer-sized arguments. The supplied arguments are multiplied, however, causing us to overflow given sufficiently large input. That in turn led to incorrect optimal I/O size reporting in some cases (RAID over RAID). Switch lcm() over to unsigned long similar to gcd() and move the function from blk-settings.c to lib. Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
parent
f11c9c5c25
commit
2cda2728aa
4 changed files with 25 additions and 11 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <linux/blkdev.h>
|
||||
#include <linux/bootmem.h> /* for max_pfn/max_low_pfn */
|
||||
#include <linux/gcd.h>
|
||||
#include <linux/lcm.h>
|
||||
#include <linux/jiffies.h>
|
||||
|
||||
#include "blk.h"
|
||||
|
|
@ -461,16 +462,6 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b)
|
|||
}
|
||||
EXPORT_SYMBOL(blk_queue_stack_limits);
|
||||
|
||||
static unsigned int lcm(unsigned int a, unsigned int b)
|
||||
{
|
||||
if (a && b)
|
||||
return (a * b) / gcd(a, b);
|
||||
else if (b)
|
||||
return b;
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
/**
|
||||
* blk_stack_limits - adjust queue_limits for stacked devices
|
||||
* @t: the stacking driver limits (top device)
|
||||
|
|
|
|||
Loading…
Reference in a new issue