mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
pinctrl: mediatek: Fix the invalid conditions
The variable count_reg_names is defined as an int type and cannot be directly compared to an unsigned int. To resolve this issue, first verify the correctness of count_reg_names. Link: https://lore.kernel.org/all/5ae93d42e4c4e70fb33bf35dcc37caebf324c8d3.camel@mediatek.com/T/ Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com> Signed-off-by: Qingliang Li <qingliang.li@mediatek.com> Link: https://lore.kernel.org/20250329024533.5279-1-ot_chhao.chang@mediatek.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
parent
136fa80169
commit
86dee87f4b
3 changed files with 8 additions and 5 deletions
|
@ -507,7 +507,7 @@ EXPORT_SYMBOL_GPL(mtk_eint_find_irq);
|
|||
|
||||
int mtk_eint_do_init(struct mtk_eint *eint)
|
||||
{
|
||||
unsigned int size, i, port, inst = 0;
|
||||
unsigned int size, i, port, virq, inst = 0;
|
||||
struct mtk_pinctrl *hw = (struct mtk_pinctrl *)eint->pctl;
|
||||
|
||||
/* If clients don't assign a specific regs, let's use generic one */
|
||||
|
@ -584,7 +584,7 @@ int mtk_eint_do_init(struct mtk_eint *eint)
|
|||
if (inst >= eint->nbase)
|
||||
continue;
|
||||
eint->pin_list[inst][eint->pins[i].index] = i;
|
||||
int virq = irq_create_mapping(eint->domain, i);
|
||||
virq = irq_create_mapping(eint->domain, i);
|
||||
irq_set_chip_and_handler(virq, &mtk_eint_irq_chip,
|
||||
handle_level_irq);
|
||||
irq_set_chip_data(virq, eint);
|
||||
|
|
|
@ -66,7 +66,7 @@ struct mtk_eint_xt {
|
|||
struct mtk_eint {
|
||||
struct device *dev;
|
||||
void __iomem **base;
|
||||
u8 nbase;
|
||||
int nbase;
|
||||
u16 *base_pin_num;
|
||||
struct irq_domain *domain;
|
||||
int irq;
|
||||
|
|
|
@ -381,10 +381,13 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
|
|||
return -ENOMEM;
|
||||
|
||||
count_reg_names = of_property_count_strings(np, "reg-names");
|
||||
if (count_reg_names < hw->soc->nbase_names)
|
||||
if (count_reg_names < 0)
|
||||
return -EINVAL;
|
||||
|
||||
hw->eint->nbase = count_reg_names - (int)hw->soc->nbase_names;
|
||||
if (hw->eint->nbase <= 0)
|
||||
return -EINVAL;
|
||||
|
||||
hw->eint->nbase = count_reg_names - hw->soc->nbase_names;
|
||||
hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase,
|
||||
sizeof(*hw->eint->base), GFP_KERNEL | __GFP_ZERO);
|
||||
if (!hw->eint->base) {
|
||||
|
|
Loading…
Add table
Reference in a new issue