On Mon, Mar 23, 2026 at 08:22:43PM -0700, Rosen Penev wrote:
> Use a flexible array member with kzalloc_flex to combine allocations
> into one.
>
> Add __counted_by for extra runtime analysis. Move counting variable
> assignment to right after allocation as required by __counted_by.
>
> Signed-off-by: Rosen Penev <[email protected]>
To be honest I'd prefer that we discussed deprecating and removing ATM
rather than cleaning it up. Is anyone using it?
> ---
> drivers/atm/nicstar.c | 17 +++++------------
> drivers/atm/nicstar.h | 4 ++--
> 2 files changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
> index 24e51343df15..2f6a3637aeab 100644
> --- a/drivers/atm/nicstar.c
> +++ b/drivers/atm/nicstar.c
> @@ -867,23 +867,17 @@ static scq_info *get_scq(ns_dev *card, int size, u32
> scd)
> if (size != VBR_SCQSIZE && size != CBR_SCQSIZE)
> return NULL;
>
> - scq = kmalloc_obj(*scq);
> + scq = kmalloc_flex(*scq, skb, size / NS_SCQE_SIZE);
> if (!scq)
> return NULL;
> - scq->org = dma_alloc_coherent(&card->pcidev->dev,
> - 2 * size, &scq->dma, GFP_KERNEL);
> +
> + scq->num_entries = size / NS_SCQE_SIZE;
> +
> + scq->org = dma_alloc_coherent(&card->pcidev->dev, 2 * size, &scq->dma,
> GFP_KERNEL);
> if (!scq->org) {
> kfree(scq);
> return NULL;
> }
> - scq->skb = kzalloc_objs(*scq->skb, size / NS_SCQE_SIZE);
> - if (!scq->skb) {
> - dma_free_coherent(&card->pcidev->dev,
> - 2 * size, scq->org, scq->dma);
> - kfree(scq);
> - return NULL;
> - }
> - scq->num_entries = size / NS_SCQE_SIZE;
AI review points out that previously the skb array was zeroed on allocation,
which is relied on by the code. But that is no longer the case.
--
pw-bot: changes requested