mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-12 16:58:53 +00:00
crypto: nx - move kzalloc() out of spinlock
Move the kzalloc() calls in nx842_probe() and nx842_OF_upd() to the top of the functions, before taking the devdata spinlock. Since kzalloc() without GFP_ATOMIC can sleep, it can't be called while holding a spinlock. Move the calls to before taking the lock. Signed-off-by: Dan Streetman <ddstreet@ieee.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
90fd73f912
commit
7f6e3aad5a
@ -724,6 +724,10 @@ static int nx842_OF_upd(struct property *new_prop)
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS);
|
||||||
|
if (!new_devdata)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
spin_lock_irqsave(&devdata_mutex, flags);
|
spin_lock_irqsave(&devdata_mutex, flags);
|
||||||
old_devdata = rcu_dereference_check(devdata,
|
old_devdata = rcu_dereference_check(devdata,
|
||||||
lockdep_is_held(&devdata_mutex));
|
lockdep_is_held(&devdata_mutex));
|
||||||
@ -733,16 +737,10 @@ static int nx842_OF_upd(struct property *new_prop)
|
|||||||
if (!old_devdata || !of_node) {
|
if (!old_devdata || !of_node) {
|
||||||
pr_err("%s: device is not available\n", __func__);
|
pr_err("%s: device is not available\n", __func__);
|
||||||
spin_unlock_irqrestore(&devdata_mutex, flags);
|
spin_unlock_irqrestore(&devdata_mutex, flags);
|
||||||
|
kfree(new_devdata);
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS);
|
|
||||||
if (!new_devdata) {
|
|
||||||
dev_err(old_devdata->dev, "%s: Could not allocate memory for device data\n", __func__);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(new_devdata, old_devdata, sizeof(*old_devdata));
|
memcpy(new_devdata, old_devdata, sizeof(*old_devdata));
|
||||||
new_devdata->counters = old_devdata->counters;
|
new_devdata->counters = old_devdata->counters;
|
||||||
|
|
||||||
@ -966,6 +964,17 @@ static int nx842_probe(struct vio_dev *viodev,
|
|||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS);
|
||||||
|
if (!new_devdata)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
new_devdata->counters = kzalloc(sizeof(*new_devdata->counters),
|
||||||
|
GFP_NOFS);
|
||||||
|
if (!new_devdata->counters) {
|
||||||
|
kfree(new_devdata);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&devdata_mutex, flags);
|
spin_lock_irqsave(&devdata_mutex, flags);
|
||||||
old_devdata = rcu_dereference_check(devdata,
|
old_devdata = rcu_dereference_check(devdata,
|
||||||
lockdep_is_held(&devdata_mutex));
|
lockdep_is_held(&devdata_mutex));
|
||||||
@ -978,21 +987,6 @@ static int nx842_probe(struct vio_dev *viodev,
|
|||||||
|
|
||||||
dev_set_drvdata(&viodev->dev, NULL);
|
dev_set_drvdata(&viodev->dev, NULL);
|
||||||
|
|
||||||
new_devdata = kzalloc(sizeof(*new_devdata), GFP_NOFS);
|
|
||||||
if (!new_devdata) {
|
|
||||||
dev_err(&viodev->dev, "%s: Could not allocate memory for device data\n", __func__);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_devdata->counters = kzalloc(sizeof(*new_devdata->counters),
|
|
||||||
GFP_NOFS);
|
|
||||||
if (!new_devdata->counters) {
|
|
||||||
dev_err(&viodev->dev, "%s: Could not allocate memory for performance counters\n", __func__);
|
|
||||||
ret = -ENOMEM;
|
|
||||||
goto error_unlock;
|
|
||||||
}
|
|
||||||
|
|
||||||
new_devdata->vdev = viodev;
|
new_devdata->vdev = viodev;
|
||||||
new_devdata->dev = &viodev->dev;
|
new_devdata->dev = &viodev->dev;
|
||||||
nx842_OF_set_defaults(new_devdata);
|
nx842_OF_set_defaults(new_devdata);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user