return attr;
}
+/*
+ * update_oa_attr - Synchronize OpenAttr's attribute pointer with modified attribute
+ * @oa2: OpenAttr structure in memory that needs to be updated
+ * @attr: Modified attribute from MFT record to duplicate
+ *
+ * Returns true on success, false on allocation failure.
+ */
+static bool update_oa_attr(struct OpenAttr *oa2, struct ATTRIB *attr)
+{
+ void *p2;
+
+ p2 = kmemdup(attr, le32_to_cpu(attr->size), GFP_NOFS);
+ if (p2) {
+ kfree(oa2->attr);
+ oa2->attr = p2;
+ return true;
+ }
+ return false;
+}
+
/*
* do_action - Common routine for the Redo and Undo Passes.
* @rlsn: If it is NULL then undo.
le16_add_cpu(&rec->hard_links, 1);
oa2 = find_loaded_attr(log, attr, rno_base);
- if (oa2) {
- void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
- GFP_NOFS);
- if (p2) {
- // run_close(oa2->run1);
- kfree(oa2->attr);
- oa2->attr = p2;
- }
- }
+ if (oa2)
+ update_oa_attr(oa2, attr);
mi->dirty = true;
break;
memmove(Add2Ptr(attr, aoff), data, dlen);
oa2 = find_loaded_attr(log, attr, rno_base);
- if (oa2) {
- void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
- GFP_NOFS);
- if (p2) {
- // run_close(&oa2->run0);
- oa2->run1 = &oa2->run0;
- kfree(oa2->attr);
- oa2->attr = p2;
- }
- }
+ if (oa2 && update_oa_attr(oa2, attr))
+ oa2->run1 = &oa2->run0;
mi->dirty = true;
break;
attr->nres.total_size = new_sz->total_size;
oa2 = find_loaded_attr(log, attr, rno_base);
- if (oa2) {
- void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
- GFP_NOFS);
- if (p2) {
- kfree(oa2->attr);
- oa2->attr = p2;
- }
- }
+ if (oa2)
+ update_oa_attr(oa2, attr);
+
mi->dirty = true;
break;