On Wed May 6, 2026 at 10:56 AM CEST, Rosen Penev wrote: > Use a flexible array member to combine allocations. > > Add __counted_by for extra runtime analysis. > > Error in case of no channels as they are required. > > Signed-off-by: Rosen Penev <[email protected]> > --- > v2: error when no channels > drivers/crypto/talitos.c | 19 +++++++------------ > drivers/crypto/talitos.h | 5 +++-- > 2 files changed, 10 insertions(+), 14 deletions(-) > > diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c > index bc61d0fe3514..bd4cc06ee13c 100644 > --- a/drivers/crypto/talitos.c > +++ b/drivers/crypto/talitos.c > @@ -3409,14 +3409,20 @@ static int talitos_probe(struct platform_device > *ofdev) > struct device *dev = &ofdev->dev; > struct device_node *np = ofdev->dev.of_node; > struct talitos_private *priv; > + unsigned int num_channels; > int i, err; > int stride; > struct resource *res; > > - priv = devm_kzalloc(dev, sizeof(struct talitos_private), GFP_KERNEL); > + if (of_property_read_u32(np, "fsl,num-channels", &num_channels)) > + return -EINVAL;
Actually, this check does not guards against the num-channels property having a value of 0 : https://elixir.bootlin.com/linux/v7.0.1/source/include/linux/of.h#L1384 This check is done here : https://elixir.bootlin.com/linux/v7.0.1/source/drivers/crypto/talitos.c#L3367 when checking the property data in the DT node. is_power_of_two does not consider that 0 is a valid power of two. Channels was not allocated because the DT node value was invalid. Ideally, the driver should validate the DT node before requesting any resources, but this is outside the scope of this patch. -- Paul Louvel, Bootlin Embedded Linux and Kernel engineering https://bootlin.com

