[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20210423094249.GN1981@kadam>
Date: Fri, 23 Apr 2021 12:42:49 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: kbuild@...ts.01.org, Arnd Bergmann <arnd@...nel.org>,
Giuseppe Cavallaro <peppe.cavallaro@...com>,
Alexandre Torgue <alexandre.torgue@...s.st.com>,
Jose Abreu <joabreu@...opsys.com>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>
Cc: lkp@...el.com, kbuild-all@...ts.01.org, netdev@...r.kernel.org,
Arnd Bergmann <arnd@...db.de>,
Maxime Coquelin <mcoquelin.stm32@...il.com>,
Ong Boon Leong <boon.leong.ong@...el.com>,
Voon Weifeng <weifeng.voon@...el.com>
Subject: Re: [PATCH] [net-next] net: stmmac: fix gcc-10 -Wrestrict warning
Hi Arnd,
url: https://github.com/0day-ci/linux/commits/Arnd-Bergmann/net-stmmac-fix-gcc-10-Wrestrict-warning/20210421-215015
base: b74523885a715463203d4ccc3cf8c85952d3701a
config: x86_64-randconfig-m001-20210421 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
New smatch warnings:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3503 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->rx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3506 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->int_name_rx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3528 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->tx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3531 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->int_name_tx_irq' 8 <= 8
Old smatch warnings:
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1708 init_dma_rx_desc_rings() warn: always true condition '(queue >= 0) => (0-u32max >= 0)'
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:1708 init_dma_rx_desc_rings() warn: always true condition '(queue >= 0) => (0-u32max >= 0)'
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3508 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->rx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3514 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->rx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3521 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->rx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3533 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->tx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3539 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->tx_irq' 8 <= 8
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3546 stmmac_request_irq_multi_msi() error: buffer overflow 'priv->tx_irq' 8 <= 8
vim +3503 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
8532f613bc78b6 Ong Boon Leong 2021-03-26 3404 static int stmmac_request_irq_multi_msi(struct net_device *dev)
8532f613bc78b6 Ong Boon Leong 2021-03-26 3405 {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3406 enum request_irq_err irq_err = REQ_IRQ_ERR_NO;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3407 struct stmmac_priv *priv = netdev_priv(dev);
8deec94c6040bb Ong Boon Leong 2021-04-01 3408 cpumask_t cpu_mask;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3409 int irq_idx = 0;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3410 char *int_name;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3411 int ret;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3412 int i;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3413
8532f613bc78b6 Ong Boon Leong 2021-03-26 3414 /* For common interrupt */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3415 int_name = priv->int_name_mac;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3416 sprintf(int_name, "%s:%s", dev->name, "mac");
8532f613bc78b6 Ong Boon Leong 2021-03-26 3417 ret = request_irq(dev->irq, stmmac_mac_interrupt,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3418 0, int_name, dev);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3419 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3420 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3421 "%s: alloc mac MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3422 __func__, dev->irq, ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3423 irq_err = REQ_IRQ_ERR_MAC;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3424 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3425 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3426
8532f613bc78b6 Ong Boon Leong 2021-03-26 3427 /* Request the Wake IRQ in case of another line
8532f613bc78b6 Ong Boon Leong 2021-03-26 3428 * is used for WoL
8532f613bc78b6 Ong Boon Leong 2021-03-26 3429 */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3430 if (priv->wol_irq > 0 && priv->wol_irq != dev->irq) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3431 int_name = priv->int_name_wol;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3432 sprintf(int_name, "%s:%s", dev->name, "wol");
8532f613bc78b6 Ong Boon Leong 2021-03-26 3433 ret = request_irq(priv->wol_irq,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3434 stmmac_mac_interrupt,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3435 0, int_name, dev);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3436 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3437 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3438 "%s: alloc wol MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3439 __func__, priv->wol_irq, ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3440 irq_err = REQ_IRQ_ERR_WOL;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3441 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3442 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3443 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3444
8532f613bc78b6 Ong Boon Leong 2021-03-26 3445 /* Request the LPI IRQ in case of another line
8532f613bc78b6 Ong Boon Leong 2021-03-26 3446 * is used for LPI
8532f613bc78b6 Ong Boon Leong 2021-03-26 3447 */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3448 if (priv->lpi_irq > 0 && priv->lpi_irq != dev->irq) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3449 int_name = priv->int_name_lpi;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3450 sprintf(int_name, "%s:%s", dev->name, "lpi");
8532f613bc78b6 Ong Boon Leong 2021-03-26 3451 ret = request_irq(priv->lpi_irq,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3452 stmmac_mac_interrupt,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3453 0, int_name, dev);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3454 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3455 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3456 "%s: alloc lpi MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3457 __func__, priv->lpi_irq, ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3458 irq_err = REQ_IRQ_ERR_LPI;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3459 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3460 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3461 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3462
8532f613bc78b6 Ong Boon Leong 2021-03-26 3463 /* Request the Safety Feature Correctible Error line in
8532f613bc78b6 Ong Boon Leong 2021-03-26 3464 * case of another line is used
8532f613bc78b6 Ong Boon Leong 2021-03-26 3465 */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3466 if (priv->sfty_ce_irq > 0 && priv->sfty_ce_irq != dev->irq) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3467 int_name = priv->int_name_sfty_ce;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3468 sprintf(int_name, "%s:%s", dev->name, "safety-ce");
8532f613bc78b6 Ong Boon Leong 2021-03-26 3469 ret = request_irq(priv->sfty_ce_irq,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3470 stmmac_safety_interrupt,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3471 0, int_name, dev);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3472 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3473 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3474 "%s: alloc sfty ce MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3475 __func__, priv->sfty_ce_irq, ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3476 irq_err = REQ_IRQ_ERR_SFTY_CE;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3477 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3478 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3479 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3480
8532f613bc78b6 Ong Boon Leong 2021-03-26 3481 /* Request the Safety Feature Uncorrectible Error line in
8532f613bc78b6 Ong Boon Leong 2021-03-26 3482 * case of another line is used
8532f613bc78b6 Ong Boon Leong 2021-03-26 3483 */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3484 if (priv->sfty_ue_irq > 0 && priv->sfty_ue_irq != dev->irq) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3485 int_name = priv->int_name_sfty_ue;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3486 sprintf(int_name, "%s:%s", dev->name, "safety-ue");
8532f613bc78b6 Ong Boon Leong 2021-03-26 3487 ret = request_irq(priv->sfty_ue_irq,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3488 stmmac_safety_interrupt,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3489 0, int_name, dev);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3490 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3491 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3492 "%s: alloc sfty ue MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3493 __func__, priv->sfty_ue_irq, ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3494 irq_err = REQ_IRQ_ERR_SFTY_UE;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3495 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3496 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3497 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3498
8532f613bc78b6 Ong Boon Leong 2021-03-26 3499 /* Request Rx MSI irq */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3500 for (i = 0; i < priv->plat->rx_queues_to_use; i++) {
e4af3ad54243da Arnd Bergmann 2021-04-21 3501 if (i > MTL_MAX_RX_QUEUES)
^^^^^^^^^^^^^^^^^^^^^
Off by one.
e4af3ad54243da Arnd Bergmann 2021-04-21 3502 break;
8532f613bc78b6 Ong Boon Leong 2021-03-26 @3503 if (priv->rx_irq[i] == 0)
^^^^^^^^^
8532f613bc78b6 Ong Boon Leong 2021-03-26 3504 continue;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3505
8532f613bc78b6 Ong Boon Leong 2021-03-26 @3506 int_name = priv->int_name_rx_irq[i];
^^^^^^^^^^^^^^^^^^^^
8532f613bc78b6 Ong Boon Leong 2021-03-26 3507 sprintf(int_name, "%s:%s-%d", dev->name, "rx", i);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3508 ret = request_irq(priv->rx_irq[i],
8532f613bc78b6 Ong Boon Leong 2021-03-26 3509 stmmac_msi_intr_rx,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3510 0, int_name, &priv->rx_queue[i]);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3511 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3512 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3513 "%s: alloc rx-%d MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3514 __func__, i, priv->rx_irq[i], ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3515 irq_err = REQ_IRQ_ERR_RX;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3516 irq_idx = i;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3517 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3518 }
8deec94c6040bb Ong Boon Leong 2021-04-01 3519 cpumask_clear(&cpu_mask);
8deec94c6040bb Ong Boon Leong 2021-04-01 3520 cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
8deec94c6040bb Ong Boon Leong 2021-04-01 3521 irq_set_affinity_hint(priv->rx_irq[i], &cpu_mask);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3522 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3523
8532f613bc78b6 Ong Boon Leong 2021-03-26 3524 /* Request Tx MSI irq */
8532f613bc78b6 Ong Boon Leong 2021-03-26 3525 for (i = 0; i < priv->plat->tx_queues_to_use; i++) {
e4af3ad54243da Arnd Bergmann 2021-04-21 3526 if (i > MTL_MAX_TX_QUEUES)
^^^^^^^^^^^^^^^^^^^^^
e4af3ad54243da Arnd Bergmann 2021-04-21 3527 break;
8532f613bc78b6 Ong Boon Leong 2021-03-26 @3528 if (priv->tx_irq[i] == 0)
8532f613bc78b6 Ong Boon Leong 2021-03-26 3529 continue;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3530
8532f613bc78b6 Ong Boon Leong 2021-03-26 @3531 int_name = priv->int_name_tx_irq[i];
8532f613bc78b6 Ong Boon Leong 2021-03-26 3532 sprintf(int_name, "%s:%s-%d", dev->name, "tx", i);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3533 ret = request_irq(priv->tx_irq[i],
8532f613bc78b6 Ong Boon Leong 2021-03-26 3534 stmmac_msi_intr_tx,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3535 0, int_name, &priv->tx_queue[i]);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3536 if (unlikely(ret < 0)) {
8532f613bc78b6 Ong Boon Leong 2021-03-26 3537 netdev_err(priv->dev,
8532f613bc78b6 Ong Boon Leong 2021-03-26 3538 "%s: alloc tx-%d MSI %d (error: %d)\n",
8532f613bc78b6 Ong Boon Leong 2021-03-26 3539 __func__, i, priv->tx_irq[i], ret);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3540 irq_err = REQ_IRQ_ERR_TX;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3541 irq_idx = i;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3542 goto irq_error;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3543 }
8deec94c6040bb Ong Boon Leong 2021-04-01 3544 cpumask_clear(&cpu_mask);
8deec94c6040bb Ong Boon Leong 2021-04-01 3545 cpumask_set_cpu(i % num_online_cpus(), &cpu_mask);
8deec94c6040bb Ong Boon Leong 2021-04-01 3546 irq_set_affinity_hint(priv->tx_irq[i], &cpu_mask);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3547 }
8532f613bc78b6 Ong Boon Leong 2021-03-26 3548
8532f613bc78b6 Ong Boon Leong 2021-03-26 3549 return 0;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3550
8532f613bc78b6 Ong Boon Leong 2021-03-26 3551 irq_error:
8532f613bc78b6 Ong Boon Leong 2021-03-26 3552 stmmac_free_irq(dev, irq_err, irq_idx);
8532f613bc78b6 Ong Boon Leong 2021-03-26 3553 return ret;
8532f613bc78b6 Ong Boon Leong 2021-03-26 3554 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Download attachment ".config.gz" of type "application/gzip" (33397 bytes)
Powered by blists - more mailing lists