From: Dan Carpenter <dan.carpenter@oracle.com>
To: horatiu.vultur@microchip.com
Cc: kernel-janitors@vger.kernel.org
Subject: [bug report] net: lan966x: add port module support
Date: Wed, 1 Dec 2021 10:11:04 +0300 [thread overview]
Message-ID: <20211201071104.GA19105@kili> (raw)
Hello Horatiu Vultur,
The patch d28d6d2e37d1: "net: lan966x: add port module support" from
Nov 29, 2021, leads to the following Smatch static checker warning:
drivers/net/ethernet/microchip/lan966x/lan966x_main.c:515 lan966x_xtr_irq_handler()
warn: duplicate check 'sz < 0' (previous on line 502)
drivers/net/ethernet/microchip/lan966x/lan966x_main.c
448 static irqreturn_t lan966x_xtr_irq_handler(int irq, void *args)
449 {
450 struct lan966x *lan966x = args;
451 int i, grp = 0, err = 0;
452
453 if (!(lan_rd(lan966x, QS_XTR_DATA_PRESENT) & BIT(grp)))
454 return IRQ_NONE;
455
456 do {
457 struct net_device *dev;
458 struct sk_buff *skb;
459 int sz = 0, buf_len;
460 u64 src_port, len;
461 u32 ifh[IFH_LEN];
462 u32 *buf;
463 u32 val;
464
465 for (i = 0; i < IFH_LEN; i++) {
466 err = lan966x_rx_frame_word(lan966x, grp, &ifh[i]);
467 if (err != 4)
468 goto recover;
469 }
470
471 err = 0;
472
473 lan966x_ifh_get_src_port(ifh, &src_port);
474 lan966x_ifh_get_len(ifh, &len);
475
476 WARN_ON(src_port >= lan966x->num_phys_ports);
477
478 dev = lan966x->ports[src_port]->dev;
479 skb = netdev_alloc_skb(dev, len);
480 if (unlikely(!skb)) {
481 netdev_err(dev, "Unable to allocate sk_buff\n");
482 err = -ENOMEM;
483 break;
484 }
485 buf_len = len - ETH_FCS_LEN;
486 buf = (u32 *)skb_put(skb, buf_len);
487
488 len = 0;
489 do {
490 sz = lan966x_rx_frame_word(lan966x, grp, &val);
491 if (sz < 0) {
492 kfree_skb(skb);
493 goto recover;
494 }
495
496 *buf++ = val;
497 len += sz;
498 } while (len < buf_len);
499
500 /* Read the FCS */
501 sz = lan966x_rx_frame_word(lan966x, grp, &val);
502 if (sz < 0) {
^^^^^^
503 kfree_skb(skb);
504 goto recover;
505 }
506
507 /* Update the statistics if part of the FCS was read before */
508 len -= ETH_FCS_LEN - sz;
509
510 if (unlikely(dev->features & NETIF_F_RXFCS)) {
511 buf = (u32 *)skb_put(skb, ETH_FCS_LEN);
512 *buf = val;
513 }
514
--> 515 if (sz < 0) {
^^^^^^
"sz" can't be negative here.
516 err = sz;
517 break;
518 }
519
520 skb->protocol = eth_type_trans(skb, dev);
521
522 netif_rx_ni(skb);
523 dev->stats.rx_bytes += len;
524 dev->stats.rx_packets++;
525
526 recover:
527 if (sz < 0 || err)
528 lan_rd(lan966x, QS_XTR_RD(grp));
529
530 } while (lan_rd(lan966x, QS_XTR_DATA_PRESENT) & BIT(grp));
531
532 return IRQ_HANDLED;
533 }
regards,
dan carpenter
reply other threads:[~2021-12-01 7:11 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211201071104.GA19105@kili \
--to=dan.carpenter@oracle.com \
--cc=horatiu.vultur@microchip.com \
--cc=kernel-janitors@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.