Re: [PATCH] block: add capacity validation in bdev_add_partition()

From: Christoph Hellwig
Date: Thu Jun 15 2023 - 04:45:44 EST


On Thu, Jun 15, 2023 at 04:09:29PM +0000, min15.li wrote:
> + if (start >= get_capacity(disk) ||
> + start + length > get_capacity(disk)) {

We need to check for overflows of the start + length value,
probably best using a helper like check_add_overflow.

Also a single tab indent (and thus the same as code below) is always
wrong for continuations, plase use either two tabs or align to the
opening brace.