Skip to content

Commit 1fe1fdb

Browse files
Varun Prakashmartinkpetersen
authored andcommitted
scsi: cxgb4i: libcxgbi: add missing module_put()
Add module_put() in cxgbi_sock_act_open_req_arp_failure() to release module reference in case of arp failure, also check return value of try_module_get() before posting active open hw cmd. Signed-off-by: Varun Prakash <varun@chelsio.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 44830d8 commit 1fe1fdb

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

drivers/scsi/cxgbi/cxgb4i/cxgb4i.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ static void do_act_establish(struct cxgbi_device *cdev, struct sk_buff *skb)
801801
(&csk->saddr), (&csk->daddr),
802802
atid, tid, csk, csk->state, csk->flags, rcv_isn);
803803

804-
module_put(THIS_MODULE);
804+
module_put(cdev->owner);
805805

806806
cxgbi_sock_get(csk);
807807
csk->tid = tid;
@@ -950,7 +950,7 @@ static void do_act_open_rpl(struct cxgbi_device *cdev, struct sk_buff *skb)
950950
if (is_neg_adv(status))
951951
goto rel_skb;
952952

953-
module_put(THIS_MODULE);
953+
module_put(cdev->owner);
954954

955955
if (status && status != CPL_ERR_TCAM_FULL &&
956956
status != CPL_ERR_CONN_EXIST &&
@@ -1713,7 +1713,11 @@ static int init_act_open(struct cxgbi_sock *csk)
17131713
csk->mtu, csk->mss_idx, csk->smac_idx);
17141714

17151715
/* must wait for either a act_open_rpl or act_open_establish */
1716-
try_module_get(THIS_MODULE);
1716+
if (!try_module_get(cdev->owner)) {
1717+
pr_err("%s, try_module_get failed.\n", ndev->name);
1718+
goto rel_resource;
1719+
}
1720+
17171721
cxgbi_sock_set_state(csk, CTP_ACTIVE_OPEN);
17181722
if (csk->csk_family == AF_INET)
17191723
send_act_open_req(csk, skb, csk->l2t);
@@ -2027,6 +2031,7 @@ static void *t4_uld_add(const struct cxgb4_lld_info *lldi)
20272031
cdev->skb_tx_rsvd = CXGB4I_TX_HEADER_LEN;
20282032
cdev->skb_rx_extra = sizeof(struct cpl_iscsi_hdr);
20292033
cdev->itp = &cxgb4i_iscsi_transport;
2034+
cdev->owner = THIS_MODULE;
20302035

20312036
cdev->pfvf = FW_VIID_PFN_G(cxgb4_port_viid(lldi->ports[0]))
20322037
<< FW_VIID_PFN_S;

drivers/scsi/cxgbi/libcxgbi.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ EXPORT_SYMBOL_GPL(cxgbi_sock_fail_act_open);
896896
void cxgbi_sock_act_open_req_arp_failure(void *handle, struct sk_buff *skb)
897897
{
898898
struct cxgbi_sock *csk = (struct cxgbi_sock *)skb->sk;
899+
struct module *owner = csk->cdev->owner;
899900

900901
log_debug(1 << CXGBI_DBG_SOCK, "csk 0x%p,%u,0x%lx,%u.\n",
901902
csk, (csk)->state, (csk)->flags, (csk)->tid);
@@ -906,6 +907,8 @@ void cxgbi_sock_act_open_req_arp_failure(void *handle, struct sk_buff *skb)
906907
spin_unlock_bh(&csk->lock);
907908
cxgbi_sock_put(csk);
908909
__kfree_skb(skb);
910+
911+
module_put(owner);
909912
}
910913
EXPORT_SYMBOL_GPL(cxgbi_sock_act_open_req_arp_failure);
911914

drivers/scsi/cxgbi/libcxgbi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ struct cxgbi_device {
468468
struct pci_dev *pdev;
469469
struct dentry *debugfs_root;
470470
struct iscsi_transport *itp;
471+
struct module *owner;
471472

472473
unsigned int pfvf;
473474
unsigned int rx_credit_thres;

0 commit comments

Comments
 (0)