提交 5ed41cc4 编写于 作者: B Bamvor Jian Zhang 提交者: Linus Walleij

gpiolib: do not allow to insert an empty gpiochip

We need to check if number of gpio is positive if there is no
such check in devicetree or acpi or whatever called before
gpiochip_add.

I suppose that devicetree and acpi do not allow insert gpiochip
with zero number but I do not know if it is enough to ignore
this check in gpiochip_add.
Signed-off-by: NBamvor Jian Zhang <bamvor.zhangjian@linaro.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
上级 ef7c7553
......@@ -325,6 +325,11 @@ int gpiochip_add(struct gpio_chip *chip)
if (!descs)
return -ENOMEM;
if (chip->ngpio == 0) {
chip_err(chip, "tried to insert a GPIO chip with zero lines\n");
return -EINVAL;
}
spin_lock_irqsave(&gpio_lock, flags);
if (base < 0) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册