[bug report] sfc: functions to register for conntrack zone offload

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Edward Cree,

The patch c3bb5c6acd4e: "sfc: functions to register for conntrack
zone offload" from Aug 7, 2023 (linux-next), leads to the following
Smatch static checker warning:

	drivers/net/ethernet/sfc/tc_conntrack.c:488 efx_tc_ct_register_zone()
	error: 'old' dereferencing possible ERR_PTR()

drivers/net/ethernet/sfc/tc_conntrack.c
    469 struct efx_tc_ct_zone *efx_tc_ct_register_zone(struct efx_nic *efx, u16 zone,
    470                                                struct nf_flowtable *ct_ft)
    471 {
    472         struct efx_tc_ct_zone *ct_zone, *old;
    473         int rc;
    474 
    475         ct_zone = kzalloc(sizeof(*ct_zone), GFP_USER);
    476         if (!ct_zone)
    477                 return ERR_PTR(-ENOMEM);
    478         ct_zone->zone = zone;
    479         old = rhashtable_lookup_get_insert_fast(&efx->tc->ct_zone_ht,
    480                                                 &ct_zone->linkage,
    481                                                 efx_tc_ct_zone_ht_params);
    482         if (old) {
    483                 /* don't need our new entry */
    484                 kfree(ct_zone);
    485                 if (!refcount_inc_not_zero(&old->ref))

rhashtable_lookup_get_insert_fast() can return NULL or error pointers.

    486                         return ERR_PTR(-EAGAIN);
    487                 /* existing entry found */
--> 488                 WARN_ON_ONCE(old->nf_ft != ct_ft);
    489                 netif_dbg(efx, drv, efx->net_dev,
    490                           "Found existing ct_zone for %u\n", zone);
    491                 return old;
    492         }
    493         ct_zone->nf_ft = ct_ft;
    494         ct_zone->efx = efx;
    495         INIT_LIST_HEAD(&ct_zone->cts);
    496         mutex_init(&ct_zone->mutex);
    497         rc = nf_flow_table_offload_add_cb(ct_ft, efx_tc_flow_block, ct_zone);
    498         netif_dbg(efx, drv, efx->net_dev, "Adding new ct_zone for %u, rc %d\n",
    499                   zone, rc);
    500         if (rc < 0)
    501                 goto fail;
    502         refcount_set(&ct_zone->ref, 1);
    503         return ct_zone;
    504 fail:
    505         rhashtable_remove_fast(&efx->tc->ct_zone_ht, &ct_zone->linkage,
    506                                efx_tc_ct_zone_ht_params);
    507         kfree(ct_zone);
    508         return ERR_PTR(rc);
    509 }

regards,
dan carpenter



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux