|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2 07/16] xen/riscv: introduce platform_get_irq()
On 16.05.2025 16:04, Oleksii Kurochko wrote:
>
> On 5/15/25 9:33 AM, Jan Beulich wrote:
>>> +int platform_get_irq(const struct dt_device_node *device, int index)
>>> +{
>>> + struct dt_irq dt_irq;
>>> + int ret;
>>> +
>>> + if ( (ret = dt_device_get_irq(device, index, &dt_irq)) != 0 )
>>> + return ret;
>>> +
>>> + if ( (ret = irq_set_type(dt_irq.irq, dt_irq.type)) != 0 )
>>> + return ret;
>>> +
>>> + return dt_irq.irq;
>> What guarantees the value to be at most INT_MAX (i.e. no silent conversion to
>> a negative value, signaling an error to the caller)? Actually, looking at
>> irq_set_type(), what guarantees irq_to_desc() there to not overrun
>> irq_desc[]?
>> There are no bounds checks in aplic_irq_xlate().
>
> I'm afraid that both aren't guaranteed. I think to have the following in
> platform_get_irq()
> should be enough:
> BUILD_BUG_ON(NR_IRQS > INT_MAX);
>
> if ( dt_irq.irq >= NR_IRQS )
> panic("irq%d is bigger then NR_IRQS(%d)\n", dt_irq.irq, NR_IRQS);
>
> Probably, the first could be dropped as I'm not sure that anyone will use
> such big
> number for NR_IRQS.
I'd say better keep it, even if largely for doc purposes.
Jan
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |