Skip to content

Commit d454b84

Browse files
Bartosz Golaszewskiopsiff
authored andcommitted
pinctrl: qcom: msm: mark certain pins as invalid for interrupts
commit 93712205ce2f1fb047739494c0399a26ea4f0890 upstream. On some platforms, the UFS-reset pin has no interrupt logic in TLMM but is nevertheless registered as a GPIO in the kernel. This enables the user-space to trigger a BUG() in the pinctrl-msm driver by running, for example: `gpiomon -c 0 113` on RB2. The exact culprit is requesting pins whose intr_detection_width setting is not 1 or 2 for interrupts. This hits a BUG() in msm_gpio_irq_set_type(). Potentially crashing the kernel due to an invalid request from user-space is not optimal, so let's go through the pins and mark those that would fail the check as invalid for the irq chip as we should not even register them as available irqs. This function can be extended if we determine that there are more corner-cases like this. Fixes: f365be0 ("pinctrl: Add Qualcomm TLMM driver") Cc: [email protected] Reviewed-by: Bjorn Andersson <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> (cherry picked from commit 275605a8b48002fe98675a5c06f3e39c09067ff2)
1 parent c65c3ac commit d454b84

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,25 @@ static bool msm_gpio_needs_dual_edge_parent_workaround(struct irq_data *d,
10351035
test_bit(d->hwirq, pctrl->skip_wake_irqs);
10361036
}
10371037

1038+
static void msm_gpio_irq_init_valid_mask(struct gpio_chip *gc,
1039+
unsigned long *valid_mask,
1040+
unsigned int ngpios)
1041+
{
1042+
struct msm_pinctrl *pctrl = gpiochip_get_data(gc);
1043+
const struct msm_pingroup *g;
1044+
int i;
1045+
1046+
bitmap_fill(valid_mask, ngpios);
1047+
1048+
for (i = 0; i < ngpios; i++) {
1049+
g = &pctrl->soc->groups[i];
1050+
1051+
if (g->intr_detection_width != 1 &&
1052+
g->intr_detection_width != 2)
1053+
clear_bit(i, valid_mask);
1054+
}
1055+
}
1056+
10381057
static int msm_gpio_irq_set_type(struct irq_data *d, unsigned int type)
10391058
{
10401059
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -1438,6 +1457,7 @@ static int msm_gpio_init(struct msm_pinctrl *pctrl)
14381457
girq->default_type = IRQ_TYPE_NONE;
14391458
girq->handler = handle_bad_irq;
14401459
girq->parents[0] = pctrl->irq;
1460+
girq->init_valid_mask = msm_gpio_irq_init_valid_mask;
14411461

14421462
ret = gpiochip_add_data(&pctrl->chip, pctrl);
14431463
if (ret) {

0 commit comments

Comments
 (0)