attrlist.c (be71b5cba2e6485e8959da7a9f9a44461a1bb074) attrlist.c (195c52bdd5d5ecfdabf5a7c6159efe299e534f84)
1// SPDX-License-Identifier: GPL-2.0
2/*
3 *
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
5 *
6 */
7
8#include <linux/blkdev.h>

--- 14 unchanged lines hidden (view full) ---

23
24 return PtrOffset(ni->attr_list.le, le) + le16_to_cpu(le->size) <=
25 ni->attr_list.size;
26}
27
28void al_destroy(struct ntfs_inode *ni)
29{
30 run_close(&ni->attr_list.run);
1// SPDX-License-Identifier: GPL-2.0
2/*
3 *
4 * Copyright (C) 2019-2021 Paragon Software GmbH, All rights reserved.
5 *
6 */
7
8#include <linux/blkdev.h>

--- 14 unchanged lines hidden (view full) ---

23
24 return PtrOffset(ni->attr_list.le, le) + le16_to_cpu(le->size) <=
25 ni->attr_list.size;
26}
27
28void al_destroy(struct ntfs_inode *ni)
29{
30 run_close(&ni->attr_list.run);
31 ntfs_free(ni->attr_list.le);
31 kfree(ni->attr_list.le);
32 ni->attr_list.le = NULL;
33 ni->attr_list.size = 0;
34 ni->attr_list.dirty = false;
35}
36
37/*
38 * ntfs_load_attr_list
39 *

--- 6 unchanged lines hidden (view full) ---

46 size_t lsize;
47 void *le = NULL;
48
49 if (ni->attr_list.size)
50 return 0;
51
52 if (!attr->non_res) {
53 lsize = le32_to_cpu(attr->res.data_size);
32 ni->attr_list.le = NULL;
33 ni->attr_list.size = 0;
34 ni->attr_list.dirty = false;
35}
36
37/*
38 * ntfs_load_attr_list
39 *

--- 6 unchanged lines hidden (view full) ---

46 size_t lsize;
47 void *le = NULL;
48
49 if (ni->attr_list.size)
50 return 0;
51
52 if (!attr->non_res) {
53 lsize = le32_to_cpu(attr->res.data_size);
54 le = ntfs_malloc(al_aligned(lsize));
54 le = kmalloc(al_aligned(lsize), GFP_NOFS);
55 if (!le) {
56 err = -ENOMEM;
57 goto out;
58 }
59 memcpy(le, resident_data(attr), lsize);
60 } else if (attr->nres.svcn) {
61 err = -EINVAL;
62 goto out;

--- 6 unchanged lines hidden (view full) ---

69
70 err = run_unpack_ex(&ni->attr_list.run, ni->mi.sbi, ni->mi.rno,
71 0, le64_to_cpu(attr->nres.evcn), 0,
72 Add2Ptr(attr, run_off),
73 le32_to_cpu(attr->size) - run_off);
74 if (err < 0)
75 goto out;
76
55 if (!le) {
56 err = -ENOMEM;
57 goto out;
58 }
59 memcpy(le, resident_data(attr), lsize);
60 } else if (attr->nres.svcn) {
61 err = -EINVAL;
62 goto out;

--- 6 unchanged lines hidden (view full) ---

69
70 err = run_unpack_ex(&ni->attr_list.run, ni->mi.sbi, ni->mi.rno,
71 0, le64_to_cpu(attr->nres.evcn), 0,
72 Add2Ptr(attr, run_off),
73 le32_to_cpu(attr->size) - run_off);
74 if (err < 0)
75 goto out;
76
77 le = ntfs_malloc(al_aligned(lsize));
77 le = kmalloc(al_aligned(lsize), GFP_NOFS);
78 if (!le) {
79 err = -ENOMEM;
80 goto out;
81 }
82
83 err = ntfs_read_run_nb(ni->mi.sbi, &ni->attr_list.run, 0, le,
84 lsize, NULL);
85 if (err)

--- 198 unchanged lines hidden (view full) ---

284 asize = al_aligned(al->size);
285 new_asize = al_aligned(new_size);
286
287 /* Scan forward to the point at which the new 'le' should be inserted. */
288 le = al_find_le_to_insert(ni, type, name, name_len, svcn);
289 off = PtrOffset(al->le, le);
290
291 if (new_size > asize) {
78 if (!le) {
79 err = -ENOMEM;
80 goto out;
81 }
82
83 err = ntfs_read_run_nb(ni->mi.sbi, &ni->attr_list.run, 0, le,
84 lsize, NULL);
85 if (err)

--- 198 unchanged lines hidden (view full) ---

284 asize = al_aligned(al->size);
285 new_asize = al_aligned(new_size);
286
287 /* Scan forward to the point at which the new 'le' should be inserted. */
288 le = al_find_le_to_insert(ni, type, name, name_len, svcn);
289 off = PtrOffset(al->le, le);
290
291 if (new_size > asize) {
292 void *ptr = ntfs_malloc(new_asize);
292 void *ptr = kmalloc(new_asize, GFP_NOFS);
293
294 if (!ptr)
295 return -ENOMEM;
296
297 memcpy(ptr, al->le, off);
298 memcpy(Add2Ptr(ptr, off + sz), le, al->size - off);
299 le = Add2Ptr(ptr, off);
293
294 if (!ptr)
295 return -ENOMEM;
296
297 memcpy(ptr, al->le, off);
298 memcpy(Add2Ptr(ptr, off + sz), le, al->size - off);
299 le = Add2Ptr(ptr, off);
300 ntfs_free(al->le);
300 kfree(al->le);
301 al->le = ptr;
302 } else {
303 memmove(Add2Ptr(le, sz), le, al->size - off);
304 }
305
306 al->size = new_size;
307
308 le->type = type;

--- 148 unchanged lines hidden ---
301 al->le = ptr;
302 } else {
303 memmove(Add2Ptr(le, sz), le, al->size - off);
304 }
305
306 al->size = new_size;
307
308 le->type = type;

--- 148 unchanged lines hidden ---