[PATCH 1/1] platform: generic: allwinner: avoid buffer overrun

Samuel Holland samuel at sholland.org
Tue Dec 27 10:49:12 PST 2022


On 12/27/22 12:39, Andreas Schwab wrote:
> On Dez 27 2022, Samuel Holland wrote:
> 
>> Anything else is either wrong or wasting space.
> 
> Not wasting space:

I am aware. However, this sort of change is not feasible for
plic_context_save()/plic_context_restore(). It would severely complicate
those functions with extra bit manipulation (thus wasting even more
space in code size). So I am happy to pay one byte here for consistency
between the two sets of functions.

Regards,
Samuel

> diff --git a/lib/utils/irqchip/plic.c b/lib/utils/irqchip/plic.c
> index d633514..901ffaa 100644
> --- a/lib/utils/irqchip/plic.c
> +++ b/lib/utils/irqchip/plic.c
> @@ -39,14 +39,14 @@ static void plic_set_priority(const struct plic_data *plic, u32 source, u32 val)
>  void plic_priority_save(const struct plic_data *plic, u8 *priority, u32 num)
>  {
>  	for (u32 i = 1; i <= num; i++)
> -		priority[i] = plic_get_priority(plic, i);
> +		priority[i - 1] = plic_get_priority(plic, i);
>  }
>  
>  void plic_priority_restore(const struct plic_data *plic, const u8 *priority,
>  			   u32 num)
>  {
>  	for (u32 i = 1; i <= num; i++)
> -		plic_set_priority(plic, i, priority[i]);
> +		plic_set_priority(plic, i, priority[i - 1]);
>  }
>  
>  static u32 plic_get_thresh(const struct plic_data *plic, u32 cntxid)
> 




More information about the opensbi mailing list