[PATCH v3] ubifs: make ubifs_[get|set]xattr atomic
Artem Bityutskiy
dedekind1 at gmail.com
Tue Aug 11 05:57:15 PDT 2015
On Fri, 2015-08-07 at 14:07 +0800, Dongsheng Yang wrote:
> + mutex_lock(&ui->ui_mutex);
> kfree(ui->data);
> ui->data = kmemdup(value, size, GFP_NOFS);
> if (!ui->data) {
> + mutex_unlock(&ui->ui_mutex);
> err = -ENOMEM;
> goto out_free;
> }
> inode->i_size = ui->ui_size = size;
> ui->data_len = size;
> + mutex_unlock(&ui->ui_mutex);
Just one note - should kmemdup() be called outside of the critical
section, to make is shorter (memory allocation is a potentially slow
operation)?
Something like:
buf = kmemdup()
mutex_lock()
kfree(ui->data)
ui->data = buf
mutex_unlock()
Artem.
More information about the linux-mtd
mailing list