Skip to content

Commit dafb558

Browse files
fsl-latifdledford
authored andcommitted
iwpm: crash fix for large connections test
During large connection test, there is a crash at wake_up() in the callback as waitq is not yet initialized. Callback can happen before iwpm_wait_complete_req() is called to initialize waitq. To resolve, using signaling semaphore instead of waitq. Signed-off-by: Mustafa Ismail <[email protected]> Reviewed-by: Tatyana E Nikolova <[email protected]> Signed-off-by: Faisal Latif <[email protected]> Reviewed-by: Steve Wise <[email protected]> Tested-by: Steve Wise <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent c1340e8 commit dafb558

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

drivers/infiniband/core/iwpm_msg.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ int iwpm_register_pid(struct iwpm_dev_data *pm_msg, u8 nl_client)
8989
if (ret)
9090
goto pid_query_error;
9191
ret = ibnl_put_attr(skb, nlh, IFNAMSIZ,
92-
pm_msg->if_name, IWPM_NLA_REG_IF_NAME);
92+
pm_msg->if_name, IWPM_NLA_REG_IF_NAME);
9393
if (ret)
9494
goto pid_query_error;
9595
ret = ibnl_put_attr(skb, nlh, IWPM_DEVNAME_SIZE,
@@ -394,7 +394,7 @@ int iwpm_register_pid_cb(struct sk_buff *skb, struct netlink_callback *cb)
394394
/* always for found nlmsg_request */
395395
kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request);
396396
barrier();
397-
wake_up(&nlmsg_request->waitq);
397+
up(&nlmsg_request->sem);
398398
return 0;
399399
}
400400
EXPORT_SYMBOL(iwpm_register_pid_cb);
@@ -463,7 +463,7 @@ int iwpm_add_mapping_cb(struct sk_buff *skb, struct netlink_callback *cb)
463463
/* always for found request */
464464
kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request);
465465
barrier();
466-
wake_up(&nlmsg_request->waitq);
466+
up(&nlmsg_request->sem);
467467
return 0;
468468
}
469469
EXPORT_SYMBOL(iwpm_add_mapping_cb);
@@ -555,7 +555,7 @@ int iwpm_add_and_query_mapping_cb(struct sk_buff *skb,
555555
/* always for found request */
556556
kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request);
557557
barrier();
558-
wake_up(&nlmsg_request->waitq);
558+
up(&nlmsg_request->sem);
559559
return 0;
560560
}
561561
EXPORT_SYMBOL(iwpm_add_and_query_mapping_cb);
@@ -749,7 +749,7 @@ int iwpm_mapping_error_cb(struct sk_buff *skb, struct netlink_callback *cb)
749749
/* always for found request */
750750
kref_put(&nlmsg_request->kref, iwpm_free_nlmsg_request);
751751
barrier();
752-
wake_up(&nlmsg_request->waitq);
752+
up(&nlmsg_request->sem);
753753
return 0;
754754
}
755755
EXPORT_SYMBOL(iwpm_mapping_error_cb);

drivers/infiniband/core/iwpm_util.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,9 @@ void iwpm_add_remote_info(struct iwpm_remote_info *rem_info)
254254
}
255255

256256
int iwpm_get_remote_info(struct sockaddr_storage *mapped_loc_addr,
257-
struct sockaddr_storage *mapped_rem_addr,
258-
struct sockaddr_storage *remote_addr,
259-
u8 nl_client)
257+
struct sockaddr_storage *mapped_rem_addr,
258+
struct sockaddr_storage *remote_addr,
259+
u8 nl_client)
260260
{
261261
struct hlist_node *tmp_hlist_node;
262262
struct hlist_head *hash_bucket_head;
@@ -322,6 +322,8 @@ struct iwpm_nlmsg_request *iwpm_get_nlmsg_request(__u32 nlmsg_seq,
322322
nlmsg_request->nl_client = nl_client;
323323
nlmsg_request->request_done = 0;
324324
nlmsg_request->err_code = 0;
325+
sema_init(&nlmsg_request->sem, 1);
326+
down(&nlmsg_request->sem);
325327
return nlmsg_request;
326328
}
327329

@@ -364,11 +366,9 @@ struct iwpm_nlmsg_request *iwpm_find_nlmsg_request(__u32 echo_seq)
364366
int iwpm_wait_complete_req(struct iwpm_nlmsg_request *nlmsg_request)
365367
{
366368
int ret;
367-
init_waitqueue_head(&nlmsg_request->waitq);
368369

369-
ret = wait_event_timeout(nlmsg_request->waitq,
370-
(nlmsg_request->request_done != 0), IWPM_NL_TIMEOUT);
371-
if (!ret) {
370+
ret = down_timeout(&nlmsg_request->sem, IWPM_NL_TIMEOUT);
371+
if (ret) {
372372
ret = -EINVAL;
373373
pr_info("%s: Timeout %d sec for netlink request (seq = %u)\n",
374374
__func__, (IWPM_NL_TIMEOUT/HZ), nlmsg_request->nlmsg_seq);

drivers/infiniband/core/iwpm_util.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct iwpm_nlmsg_request {
6969
u8 nl_client;
7070
u8 request_done;
7171
u16 err_code;
72-
wait_queue_head_t waitq;
72+
struct semaphore sem;
7373
struct kref kref;
7474
};
7575

0 commit comments

Comments
 (0)