Tejun Heo 464d1387ac writeback: use |1 instead of +1 to protect against div by zero
mm/page-writeback.c has several places where 1 is added to the divisor
to prevent division by zero exceptions; however, if the original
divisor is equivalent to -1, adding 1 leads to division by zero.

There are three places where +1 is used for this purpose - one in
pos_ratio_polynom() and two in bdi_position_ratio().  The second one
in bdi_position_ratio() actually triggered div-by-zero oops on a
machine running a 3.10 kernel.  The divisor is

  x_intercept - bdi_setpoint + 1 == span + 1

span is confirmed to be (u32)-1.  It isn't clear how it ended up that
but it could be from write bandwidth calculation underflow fixed by
c72efb658f7c ("writeback: fix possible underflow in write bandwidth
calculation").

At any rate, +1 isn't a proper protection against div-by-zero.  This
patch converts all +1 protections to |1.  Note that
bdi_update_dirty_ratelimit() was already using |1 before this patch.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: stable@vger.kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@fb.com>
2015-04-23 10:36:33 -06:00
..
2015-04-14 16:49:00 -07:00
2015-02-16 17:56:03 -08:00
2012-01-03 22:54:56 -05:00
2015-04-15 16:35:18 -07:00
2015-04-15 16:35:19 -07:00
2011-07-26 16:49:47 -07:00
2015-04-14 16:49:00 -07:00
2015-04-15 16:35:18 -07:00
2015-02-16 17:56:03 -08:00
2015-04-14 16:49:06 -07:00
2015-04-15 16:35:19 -07:00
2015-02-11 17:06:02 -08:00
2015-04-11 22:27:56 -04:00
2015-04-15 16:35:16 -07:00
2015-03-24 13:41:54 -04:00
2015-04-15 16:35:18 -07:00
2015-04-11 22:29:40 -04:00
2015-04-14 16:49:03 -07:00
2015-04-15 16:35:18 -07:00