On Mon, Feb 14, 2022 at 12:00:24PM +1100, Jonathan Gray wrote:
> On Sun, Feb 13, 2022 at 03:17:27PM +0100, Theo Buehler wrote:
> > On Sun, Feb 13, 2022 at 02:30:21PM +0100, Tobias Heider wrote:
> > > OF_getproplen() will return -1 if "reset-gpios" is not found which
> > > currently causes a panic:
> > > 
> > > panic: malloc: allocation too large, type = 2, size = 4294967295
> > > 
> > > Below is a fix.
> > 
> > There are more of these:
> > 
> > dev/ofw/ofw_regulator.c:336:    if ((glen = OF_getproplen(node, "gpios")) 
> > <= 0)
> > dev/ofw/ofw_regulator.c:338:    if ((slen = OF_getproplen(node, "states")) 
> > <= 0)
> > dev/ofw/ofw_regulator.c:401:    if ((glen = OF_getproplen(node, "gpios")) 
> > <= 0)
> > dev/ofw/ofw_regulator.c:403:    if ((slen = OF_getproplen(node, "states")) 
> > <= 0)
> > 
> > where glen and slen are size_t and

Thanks.

ok

> 
> Index: ofw_regulator.c
> ===================================================================
> RCS file: /cvs/src/sys/dev/ofw/ofw_regulator.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 ofw_regulator.c
> --- ofw_regulator.c   23 Dec 2020 11:58:36 -0000      1.15
> +++ ofw_regulator.c   14 Feb 2022 00:55:28 -0000
> @@ -328,8 +328,7 @@ regulator_gpio_get(int node)
>  {
>       uint32_t *gpio, *gpios, *states;
>       uint32_t idx, value;
> -     size_t glen, slen;
> -     int i;
> +     int glen, slen, i;
>  
>       pinctrl_byname(node, "default");
>  
> @@ -377,10 +376,9 @@ int
>  regulator_gpio_set(int node, uint32_t value)
>  {
>       uint32_t *gpio, *gpios, *states;
> -     size_t glen, slen;
>       uint32_t min, max;
>       uint32_t idx;
> -     int i;
> +     int glen, slen, i;
>  
>       pinctrl_byname(node, "default");
>  

Reply via email to