|
@@ -1373,8 +1373,12 @@ done:
|
|
|
#define VALIDATE_DESC(desc) do { \
|
|
|
if (!desc) \
|
|
|
return 0; \
|
|
|
+ if (IS_ERR(desc)) { \
|
|
|
+ pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
|
|
|
+ return PTR_ERR(desc); \
|
|
|
+ } \
|
|
|
if (!desc->gdev) { \
|
|
|
- pr_warn("%s: invalid GPIO\n", __func__); \
|
|
|
+ pr_warn("%s: invalid GPIO (no device)\n", __func__); \
|
|
|
return -EINVAL; \
|
|
|
} \
|
|
|
if ( !desc->gdev->chip ) { \
|
|
@@ -1386,8 +1390,12 @@ done:
|
|
|
#define VALIDATE_DESC_VOID(desc) do { \
|
|
|
if (!desc) \
|
|
|
return; \
|
|
|
+ if (IS_ERR(desc)) { \
|
|
|
+ pr_warn("%s: invalid GPIO (errorpointer)\n", __func__); \
|
|
|
+ return; \
|
|
|
+ } \
|
|
|
if (!desc->gdev) { \
|
|
|
- pr_warn("%s: invalid GPIO\n", __func__); \
|
|
|
+ pr_warn("%s: invalid GPIO (no device)\n", __func__); \
|
|
|
return; \
|
|
|
} \
|
|
|
if (!desc->gdev->chip) { \
|
|
@@ -2056,7 +2064,14 @@ int gpiod_to_irq(const struct gpio_desc *desc)
|
|
|
struct gpio_chip *chip;
|
|
|
int offset;
|
|
|
|
|
|
- VALIDATE_DESC(desc);
|
|
|
+ /*
|
|
|
+ * Cannot VALIDATE_DESC() here as gpiod_to_irq() consumer semantics
|
|
|
+ * requires this function to not return zero on an invalid descriptor
|
|
|
+ * but rather a negative error number.
|
|
|
+ */
|
|
|
+ if (!desc || IS_ERR(desc) || !desc->gdev || !desc->gdev->chip)
|
|
|
+ return -EINVAL;
|
|
|
+
|
|
|
chip = desc->gdev->chip;
|
|
|
offset = gpio_chip_hwgpio(desc);
|
|
|
if (chip->to_irq) {
|