From: Dan Carpenter <dan.carpenter@linaro.org>
To: Dimitris Michailidis <d.michailidis@fungible.com>
Cc: netdev@vger.kernel.org
Subject: [bug report] net/funeth: probing and netdev ops
Date: Tue, 11 Mar 2025 18:01:33 +0300 [thread overview]
Message-ID: <ec0b7b3e-0d69-4fa7-bfd2-b3b110fe237d@stanley.mountain> (raw)
Hello Dimitris Michailidis,
Commit ee6373ddf3a9 ("net/funeth: probing and netdev ops") from Feb
24, 2022 (linux-next), leads to the following Smatch static checker
warning:
drivers/net/ethernet/fungible/funeth/funeth_main.c:333 fun_alloc_queue_irqs()
warn: 'irq' can also be NULL
drivers/net/ethernet/fungible/funeth/funeth_main.c
319 static int fun_alloc_queue_irqs(struct net_device *dev, unsigned int ntx,
320 unsigned int nrx)
321 {
322 struct funeth_priv *fp = netdev_priv(dev);
323 int node = dev_to_node(&fp->pdev->dev);
324 struct fun_irq *irq;
325 unsigned int i;
326
327 for (i = fp->num_tx_irqs; i < ntx; i++) {
328 irq = fun_alloc_qirq(fp, i, node, 0);
^^^^^^^^^^^^^
The fun_alloc_qirq() function can return NULL.
329 if (IS_ERR(irq))
330 return PTR_ERR(irq);
331
332 fp->num_tx_irqs++;
--> 333 netif_napi_add_tx(dev, &irq->napi, fun_txq_napi_poll);
334 }
335
The problem is this:
249 static struct fun_irq *fun_alloc_qirq(struct funeth_priv *fp, unsigned int idx,
250 int node, unsigned int xa_idx_offset)
251 {
252 struct fun_irq *irq;
253 int cpu, res;
254
255 cpu = cpumask_local_spread(idx, node);
256 node = cpu_to_mem(cpu);
257
258 irq = kzalloc_node(sizeof(*irq), GFP_KERNEL, node);
259 if (!irq)
260 return ERR_PTR(-ENOMEM);
261
262 res = fun_reserve_irqs(fp->fdev, 1, &irq->irq_idx);
263 if (res != 1)
264 goto free_irq;
The error code is not set on this path. This is the only caller. Why not
modify fun_reserve_irqs() to just return zero on success and negative
failures? Are we likely to need the current API in the near future?
265
266 res = xa_insert(&fp->irqs, idx + xa_idx_offset, irq, GFP_KERNEL);
267 if (res)
268 goto release_irq;
269
270 irq->irq = pci_irq_vector(fp->pdev, irq->irq_idx);
271 cpumask_set_cpu(cpu, &irq->affinity_mask);
272 irq->aff_notify.notify = fun_irq_aff_notify;
273 irq->aff_notify.release = fun_irq_aff_release;
274 irq->state = FUN_IRQ_INIT;
275 return irq;
276
277 release_irq:
278 fun_release_irqs(fp->fdev, 1, &irq->irq_idx);
279 free_irq:
280 kfree(irq);
281 return ERR_PTR(res);
282 }
regards,
dan carpenter
next reply other threads:[~2025-03-11 15:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-11 15:01 Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-08-15 11:29 [bug report] net/funeth: probing and netdev ops Dan Carpenter
2024-08-15 15:59 ` Jakub Kicinski
2024-08-16 9:36 ` Dimitris Michailidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ec0b7b3e-0d69-4fa7-bfd2-b3b110fe237d@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=d.michailidis@fungible.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox