Commit 05e52dd7 authored by Philipp Reisner's avatar Philipp Reisner Committed by David S. Miller

[CONNECTOR]: Bugfix for cn_call_callback()

When system under heavy stress and must allocate new work
instead of reusing old one, new work must use correct
completion callback.

Patch is based on Philipp's and Lars' work.
I only cleaned small stuff (and removed spaces instead of tabs).
Signed-off-by: default avatarPhilipp Reisner <philipp.reisner@linbit.com>
Signed-off-by: default avatarLars Ellenberg <lars.ellenberg@linbit.com>
Signed-off-by: default avatarEvgeniy Polyakov <johnpol@2ka.mipt.ru>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 151a9931
...@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(cn_netlink_send); ...@@ -128,7 +128,7 @@ EXPORT_SYMBOL_GPL(cn_netlink_send);
*/ */
static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), void *data) static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), void *data)
{ {
struct cn_callback_entry *__cbq; struct cn_callback_entry *__cbq, *__new_cbq;
struct cn_dev *dev = &cdev; struct cn_dev *dev = &cdev;
int err = -ENODEV; int err = -ENODEV;
...@@ -148,27 +148,27 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v ...@@ -148,27 +148,27 @@ static int cn_call_callback(struct cn_msg *msg, void (*destruct_data)(void *), v
} else { } else {
struct cn_callback_data *d; struct cn_callback_data *d;
__cbq = kzalloc(sizeof(*__cbq), GFP_ATOMIC); err = -ENOMEM;
if (__cbq) { __new_cbq = kzalloc(sizeof(struct cn_callback_entry), GFP_ATOMIC);
d = &__cbq->data; if (__new_cbq) {
d = &__new_cbq->data;
d->callback_priv = msg; d->callback_priv = msg;
d->callback = __cbq->data.callback; d->callback = __cbq->data.callback;
d->ddata = data; d->ddata = data;
d->destruct_data = destruct_data; d->destruct_data = destruct_data;
d->free = __cbq; d->free = __new_cbq;
INIT_WORK(&__cbq->work, INIT_WORK(&__new_cbq->work,
&cn_queue_wrapper); &cn_queue_wrapper);
if (queue_work(dev->cbdev->cn_queue, if (queue_work(dev->cbdev->cn_queue,
&__cbq->work)) &__new_cbq->work))
err = 0; err = 0;
else { else {
kfree(__cbq); kfree(__new_cbq);
err = -EINVAL; err = -EINVAL;
} }
} else }
err = -ENOMEM;
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment