Skip to contentSkip to conversation

cxgbit: add files for cxgbit.ko

bug report Dan Carpenter 1 participant 1 message Jan 21, 2022 SCSI target

lore
Share & tools
lore
#0 lore raw

Hello Varun Prakash,

The patch 9730ffcb8957: "cxgbit: add files for cxgbit.ko" from Apr 20, 2016, leads to the following Smatch static checker warning:

drivers/target/iscsi/cxgbit/cxgbit_cm.c:561 __cxgbit_free_cdev_np()
warn: inconsistent refcounting 'cnp->kref.refcount.refs.counter'
inc on: 548
dec on: 542

drivers/target/iscsi/cxgbit/cxgbit_cm.c

   517        static int
   518        __cxgbit_free_cdev_np(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
   519        {

520 int stid, ret;
521 bool ipv6 = false;
522
523 stid = cxgbit_np_hash_del(cdev, cnp);
524 if (stid < 0)
525 return -EINVAL;
526 if (!test_bit(CDEV_STATE_UP, &cdev->flags))
527 return -EINVAL;
528
529 if (cnp->np->np_sockaddr.ss_family == AF_INET6)
530 ipv6 = true;
531
532 cxgbit_get_cnp(cnp);

get here

   533                cxgbit_init_wr_wait(&cnp->com.wr_wait);
   534                ret = cxgb4_remove_server(cdev->lldi.ports[0], stid,
   535                                          cdev->lldi.rxq_ids[0], ipv6);
   536
   537                if (ret > 0)
   538                        ret = net_xmit_errno(ret);
   539
   540                if (ret) {
   541                        cxgbit_put_cnp(cnp);

put here

542 return ret;
543 }
544
545 ret = cxgbit_wait_for_reply(cdev, &cnp->com.wr_wait,
546 0, 10, __func__);
547 if (ret == -ETIMEDOUT)
548 return ret;

Should this error path put as well?

   549
   550                if (ipv6 && cnp->com.cdev) {
   551                        struct sockaddr_in6 *sin6;
   552
   553                        sin6 = (struct sockaddr_in6 *)&cnp->com.local_addr;
   554                        cxgb4_clip_release(cdev->lldi.ports[0],
   555                                           (const u32 *)&sin6->sin6_addr.s6_addr,
   556                                           1);
   557                }
   558
   559                cxgb4_free_stid(cdev->lldi.tids, stid,
   560                                cnp->com.local_addr.ss_family);
   561                return 0;

regards,
dan carpenter