run_init(run);
 
        /* make a copy of original attribute */
-       attr_s = ntfs_memdup(attr, asize);
+       attr_s = kmemdup(attr, asize, GFP_NOFS);
        if (!attr_s) {
                err = -ENOMEM;
                goto out;
        if (err)
                goto out3;
 
-       ntfs_free(attr_s);
+       kfree(attr_s);
        attr->nres.data_size = cpu_to_le64(rsize);
        attr->nres.valid_size = attr->nres.data_size;
 
        run_deallocate(sbi, run, false);
        run_close(run);
 out1:
-       ntfs_free(attr_s);
+       kfree(attr_s);
        /*reinsert le*/
 out:
        return err;
 
 void al_destroy(struct ntfs_inode *ni)
 {
        run_close(&ni->attr_list.run);
-       ntfs_free(ni->attr_list.le);
+       kfree(ni->attr_list.le);
        ni->attr_list.le = NULL;
        ni->attr_list.size = 0;
        ni->attr_list.dirty = false;
 
        if (!attr->non_res) {
                lsize = le32_to_cpu(attr->res.data_size);
-               le = ntfs_malloc(al_aligned(lsize));
+               le = kmalloc(al_aligned(lsize), GFP_NOFS);
                if (!le) {
                        err = -ENOMEM;
                        goto out;
                if (err < 0)
                        goto out;
 
-               le = ntfs_malloc(al_aligned(lsize));
+               le = kmalloc(al_aligned(lsize), GFP_NOFS);
                if (!le) {
                        err = -ENOMEM;
                        goto out;
        off = PtrOffset(al->le, le);
 
        if (new_size > asize) {
-               void *ptr = ntfs_malloc(new_asize);
+               void *ptr = kmalloc(new_asize, GFP_NOFS);
 
                if (!ptr)
                        return -ENOMEM;
                memcpy(ptr, al->le, off);
                memcpy(Add2Ptr(ptr, off + sz), le, al->size - off);
                le = Add2Ptr(ptr, off);
-               ntfs_free(al->le);
+               kfree(al->le);
                al->le = ptr;
        } else {
                memmove(Add2Ptr(le, sz), le, al->size - off);
 
 {
        struct rb_node *node, *next;
 
-       ntfs_free(wnd->free_bits);
+       kfree(wnd->free_bits);
        run_close(&wnd->run);
 
        node = rb_first(&wnd->start_tree);
        if (!wnd->bits_last)
                wnd->bits_last = wbits;
 
-       wnd->free_bits = ntfs_zalloc(wnd->nwnd * sizeof(u16));
+       wnd->free_bits = kzalloc(wnd->nwnd * sizeof(u16), GFP_NOFS);
        if (!wnd->free_bits)
                return -ENOMEM;
 
                new_last = wbits;
 
        if (new_wnd != wnd->nwnd) {
-               new_free = ntfs_malloc(new_wnd * sizeof(u16));
+               new_free = kmalloc(new_wnd * sizeof(u16), GFP_NOFS);
                if (!new_free)
                        return -ENOMEM;
 
                               wnd->nwnd * sizeof(short));
                memset(new_free + wnd->nwnd, 0,
                       (new_wnd - wnd->nwnd) * sizeof(short));
-               ntfs_free(wnd->free_bits);
+               kfree(wnd->free_bits);
                wnd->free_bits = new_free;
        }
 
 
 #define ntfs_inode_warn(inode, fmt, ...)                                       \
        ntfs_inode_printk(inode, KERN_WARNING fmt, ##__VA_ARGS__)
 
-#define ntfs_malloc(s)         kmalloc(s, GFP_NOFS)
-#define ntfs_zalloc(s)         kzalloc(s, GFP_NOFS)
-#define ntfs_vmalloc(s)                kvmalloc(s, GFP_KERNEL)
-#define ntfs_free(p)           kfree(p)
-#define ntfs_vfree(p)          kvfree(p)
-#define ntfs_memdup(src, len)  kmemdup(src, len, GFP_NOFS)
-
 #endif /* _LINUX_NTFS3_DEBUG_H */
 // clang-format on
 
                return -EOPNOTSUPP;
        }
 
-       pages = ntfs_malloc(pages_per_frame * sizeof(struct page *));
+       pages = kmalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
        if (!pages)
                return -ENOMEM;
 
        }
 
 out:
-       ntfs_free(pages);
+       kfree(pages);
 
        current->backing_dev_info = NULL;
 
 
 {
        struct mft_inode *m;
 
-       m = ntfs_zalloc(sizeof(struct mft_inode));
+       m = kzalloc(sizeof(struct mft_inode), GFP_NOFS);
        if (!m)
                return false;
 
        run_deallocate(sbi, &ni->attr_list.run, true);
        run_close(&ni->attr_list.run);
        ni->attr_list.size = 0;
-       ntfs_free(ni->attr_list.le);
+       kfree(ni->attr_list.le);
        ni->attr_list.le = NULL;
        ni->attr_list.dirty = false;
 
         * Skip estimating exact memory requirement
         * Looks like one record_size is always enough
         */
-       le = ntfs_malloc(al_aligned(rs));
+       le = kmalloc(al_aligned(rs), GFP_NOFS);
        if (!le) {
                err = -ENOMEM;
                goto out;
        goto out;
 
 out1:
-       ntfs_free(ni->attr_list.le);
+       kfree(ni->attr_list.le);
        ni->attr_list.le = NULL;
        ni->attr_list.size = 0;
 
        idx = (vbo - frame_vbo) >> PAGE_SHIFT;
 
        pages_per_frame = frame_size >> PAGE_SHIFT;
-       pages = ntfs_zalloc(pages_per_frame * sizeof(struct page *));
+       pages = kzalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
        if (!pages) {
                err = -ENOMEM;
                goto out;
 
 out:
        /* At this point, err contains 0 or -EIO depending on the "critical" page */
-       ntfs_free(pages);
+       kfree(pages);
        unlock_page(page);
 
        return err;
        frame_bits = ni_ext_compress_bits(ni);
        frame_size = 1u << frame_bits;
        pages_per_frame = frame_size >> PAGE_SHIFT;
-       pages = ntfs_zalloc(pages_per_frame * sizeof(struct page *));
+       pages = kzalloc(pages_per_frame * sizeof(struct page *), GFP_NOFS);
        if (!pages) {
                err = -ENOMEM;
                goto out;
        mapping->a_ops = &ntfs_aops;
 
 out:
-       ntfs_free(pages);
+       kfree(pages);
        if (err) {
                make_bad_inode(inode);
                ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
                goto out1;
        }
 
-       pages_disk = ntfs_zalloc(npages_disk * sizeof(struct page *));
+       pages_disk = kzalloc(npages_disk * sizeof(struct page *), GFP_NOFS);
        if (!pages_disk) {
                err = -ENOMEM;
                goto out2;
                        put_page(pg);
                }
        }
-       ntfs_free(pages_disk);
+       kfree(pages_disk);
 
 out2:
 #ifdef CONFIG_NTFS3_LZX_XPRESS
                goto out;
        }
 
-       pages_disk = ntfs_zalloc(pages_per_frame * sizeof(struct page *));
+       pages_disk = kzalloc(pages_per_frame * sizeof(struct page *),
+                            GFP_NOFS);
        if (!pages_disk) {
                err = -ENOMEM;
                goto out;
        compr_size = compress_lznt(frame_mem, frame_size, frame_ondisk,
                                   frame_size, sbi->compress.lznt);
        mutex_unlock(&sbi->compress.mtx_lznt);
-       ntfs_free(lznt);
+       kfree(lznt);
 
        if (compr_size + sbi->cluster_size > frame_size) {
                /* frame is not compressed */
                        put_page(pg);
                }
        }
-       ntfs_free(pages_disk);
+       kfree(pages_disk);
 out:
        return err;
 }
 
 static void lcb_put(struct lcb *lcb)
 {
        if (lcb->alloc)
-               ntfs_free(lcb->log_rec);
-       ntfs_free(lcb->lrh);
-       ntfs_free(lcb);
+               kfree(lcb->log_rec);
+       kfree(lcb->lrh);
+       kfree(lcb);
 }
 
 /*
        u32 off;
        u32 bytes = esize * used + sizeof(struct RESTART_TABLE);
        u32 lf = sizeof(struct RESTART_TABLE) + (used - 1) * esize;
-       struct RESTART_TABLE *t = ntfs_zalloc(bytes);
+       struct RESTART_TABLE *t = kzalloc(bytes, GFP_NOFS);
 
        t->size = cpu_to_le16(esize);
        t->used = cpu_to_le16(used);
 
        rt->total = tbl->total;
 
-       ntfs_free(tbl);
+       kfree(tbl);
        return rt;
 }
 
                return -EINVAL;
 
        if (!*buffer) {
-               to_free = ntfs_malloc(bytes);
+               to_free = kmalloc(bytes, GFP_NOFS);
                if (!to_free)
                        return -ENOMEM;
                *buffer = to_free;
 
 out:
        if (err && to_free) {
-               ntfs_free(to_free);
+               kfree(to_free);
                *buffer = NULL;
        }
 
                        struct restart_info *info)
 {
        u32 skip, vbo;
-       struct RESTART_HDR *r_page = ntfs_malloc(DefaultLogPageSize);
+       struct RESTART_HDR *r_page = kmalloc(DefaultLogPageSize, GFP_NOFS);
 
        if (!r_page)
                return -ENOMEM;
                /* Read the entire restart area */
                sys_page_size = le32_to_cpu(r_page->sys_page_size);
                if (DefaultLogPageSize != sys_page_size) {
-                       ntfs_free(r_page);
-                       r_page = ntfs_zalloc(sys_page_size);
+                       kfree(r_page);
+                       r_page = kzalloc(sys_page_size, GFP_NOFS);
                        if (!r_page)
                                return -ENOMEM;
 
                                          (struct RECORD_PAGE_HDR **)&r_page,
                                          &usa_error)) {
                                /* ignore any errors */
-                               ntfs_free(r_page);
+                               kfree(r_page);
                                r_page = NULL;
                                continue;
                        }
                }
        }
 
-       ntfs_free(r_page);
+       kfree(r_page);
 
        return 0;
 }
 static struct RESTART_AREA *log_create_ra(struct ntfs_log *log)
 {
        struct CLIENT_REC *cr;
-       struct RESTART_AREA *ra = ntfs_zalloc(log->restart_size);
+       struct RESTART_AREA *ra = kzalloc(log->restart_size, GFP_NOFS);
 
        if (!ra)
                return NULL;
        if (!is_lsn_in_file(log, *lsn))
                *lsn = 0;
 
-       ntfs_free(page);
+       kfree(page);
 
        return 0;
 }
                second_off = 0x12 * log->page_size;
 
                // 0x10 == 0x12 - 0x2
-               page_bufs = ntfs_malloc(log->page_size * 0x10);
+               page_bufs = kmalloc(log->page_size * 0x10, GFP_NOFS);
                if (!page_bufs)
                        return -ENOMEM;
        } else {
        /* Read second tail page (at pos 3/0x12000) */
        if (read_log_page(log, second_off, &second_tail, &usa_error) ||
            usa_error || second_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) {
-               ntfs_free(second_tail);
+               kfree(second_tail);
                second_tail = NULL;
                second_file_off = 0;
                lsn2 = 0;
        /* Read first tail page (at pos 2/0x2000 ) */
        if (read_log_page(log, final_off, &first_tail, &usa_error) ||
            usa_error || first_tail->rhdr.sign != NTFS_RCRD_SIGNATURE) {
-               ntfs_free(first_tail);
+               kfree(first_tail);
                first_tail = NULL;
                first_file_off = 0;
                lsn1 = 0;
                        page_pos = page_cnt = 1;
                }
        } else {
-               ntfs_free(first_tail);
-               ntfs_free(second_tail);
+               kfree(first_tail);
+               kfree(second_tail);
                goto tail_read;
        }
 
-       ntfs_free(first_tail_prev);
+       kfree(first_tail_prev);
        first_tail_prev = first_tail;
        final_off_prev = first_file_off;
        first_tail = NULL;
 
-       ntfs_free(second_tail_prev);
+       kfree(second_tail_prev);
        second_tail_prev = second_tail;
        second_off_prev = second_file_off;
        second_tail = NULL;
        }
 
        curpage_off = nextpage_off;
-       ntfs_free(page);
+       kfree(page);
        page = NULL;
        reuse_page = 0;
        goto next_page;
        cur_pos = 2;
 
 next_test_page:
-       ntfs_free(tst_page);
+       kfree(tst_page);
        tst_page = NULL;
 
        /* Walk through the file, reading log pages */
        }
 
        /* Call our routine to check this log page */
-       ntfs_free(tst_page);
+       kfree(tst_page);
        tst_page = NULL;
 
        err = read_log_page(log, nextpage_off, &tst_page, &usa_error);
                        u64 off = hdr_file_off(log, tmp_page);
 
                        if (!page) {
-                               page = ntfs_malloc(log->page_size);
+                               page = kmalloc(log->page_size, GFP_NOFS);
                                if (!page)
                                        return -ENOMEM;
                        }
        }
 
 out:
-       ntfs_free(second_tail);
-       ntfs_free(first_tail);
-       ntfs_free(page);
-       ntfs_free(tst_page);
-       ntfs_free(page_bufs);
+       kfree(second_tail);
+       kfree(first_tail);
+       kfree(page);
+       kfree(tst_page);
+       kfree(page_bufs);
 
        return err;
 }
        }
 
 out:
-       ntfs_free(ph);
+       kfree(ph);
        return err;
 }
 
                goto out;
        }
 
-       rst = ntfs_malloc(len);
+       rst = kmalloc(len, GFP_NOFS);
        if (!rst) {
                err = -ENOMEM;
                goto out;
        rst = NULL;
 
 out:
-       ntfs_free(rh);
-       ntfs_free(rst);
+       kfree(rh);
+       kfree(rst);
 
        return err;
 }
         * put a pointer to the log record the context block
         */
        if (rh->flags & LOG_RECORD_MULTI_PAGE) {
-               void *lr = ntfs_malloc(len);
+               void *lr = kmalloc(len, GFP_NOFS);
 
                if (!lr)
                        return -ENOMEM;
        if (!verify_client_lsn(log, cr, lsn))
                return -EINVAL;
 
-       lcb = ntfs_zalloc(sizeof(struct lcb));
+       lcb = kzalloc(sizeof(struct lcb), GFP_NOFS);
        if (!lcb)
                return -ENOMEM;
        lcb->client = log->client_id;
                        break;
 
                if (hdr != lcb->lrh)
-                       ntfs_free(hdr);
+                       kfree(hdr);
 
                hdr = NULL;
                err = read_log_page(log, lsn_to_vbo(log, current_lsn),
                           sizeof(struct CLIENT_ID))) {
                        /*err = -EINVAL; */
                } else if (LfsClientRecord == hdr->record_type) {
-                       ntfs_free(lcb->lrh);
+                       kfree(lcb->lrh);
                        lcb->lrh = hdr;
                        *lsn = current_lsn;
                        return 0;
 
 out:
        if (hdr != lcb->lrh)
-               ntfs_free(hdr);
+               kfree(hdr);
        return err;
 
 check_undo_next:
                            (struct RECORD_PAGE_HDR **)&hdr, NULL);
        if (err)
                return err;
-       ntfs_free(lcb->lrh);
+       kfree(lcb->lrh);
        lcb->lrh = hdr;
 
        *lsn = next_lsn;
                return 0;
 
        if (lcb->alloc)
-               ntfs_free(lcb->log_rec);
+               kfree(lcb->log_rec);
 
        lcb->log_rec = NULL;
        lcb->alloc = false;
-       ntfs_free(lcb->lrh);
+       kfree(lcb->lrh);
        lcb->lrh = NULL;
 
        return find_log_rec(log, *lsn, lcb);
        u32 asize = name_size +
                    (is_ext ? SIZEOF_NONRESIDENT_EX : SIZEOF_NONRESIDENT);
 
-       attr = ntfs_zalloc(asize);
+       attr = kzalloc(asize, GFP_NOFS);
        if (!attr)
                return NULL;
 
                if (inode) {
                        mi = &ntfs_i(inode)->mi;
                } else if (op == InitializeFileRecordSegment) {
-                       mi = ntfs_zalloc(sizeof(struct mft_inode));
+                       mi = kzalloc(sizeof(struct mft_inode), GFP_NOFS);
                        if (!mi)
                                return -ENOMEM;
                        err = mi_format_new(mi, sbi, rno, 0, false);
                if (attr->type == ATTR_ALLOC)
                        bytes = (bytes + 511) & ~511; // align
 
-               buffer_le = ntfs_malloc(bytes);
+               buffer_le = kmalloc(bytes, GFP_NOFS);
                if (!buffer_le)
                        return -ENOMEM;
 
 
                oa2 = find_loaded_attr(log, attr, rno_base);
                if (oa2) {
-                       void *p2 = ntfs_memdup(attr, le32_to_cpu(attr->size));
-
+                       void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
+                                          GFP_NOFS);
                        if (p2) {
                                // run_close(oa2->run1);
-                               ntfs_free(oa2->attr);
+                               kfree(oa2->attr);
                                oa2->attr = p2;
                        }
                }
 
                oa2 = find_loaded_attr(log, attr, rno_base);
                if (oa2) {
-                       void *p2 = ntfs_memdup(attr, le32_to_cpu(attr->size));
-
+                       void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
+                                          GFP_NOFS);
                        if (p2) {
                                // run_close(&oa2->run0);
                                oa2->run1 = &oa2->run0;
-                               ntfs_free(oa2->attr);
+                               kfree(oa2->attr);
                                oa2->attr = p2;
                        }
                }
 
                oa2 = find_loaded_attr(log, attr, rno_base);
                if (oa2) {
-                       void *p2 = ntfs_memdup(attr, le32_to_cpu(attr->size));
-
+                       void *p2 = kmemdup(attr, le32_to_cpu(attr->size),
+                                          GFP_NOFS);
                        if (p2) {
-                               ntfs_free(oa2->attr);
+                               kfree(oa2->attr);
                                oa2->attr = p2;
                        }
                }
        else if (mi != mi2_child)
                mi_put(mi);
 
-       ntfs_free(buffer_le);
+       kfree(buffer_le);
 
        return err;
 
        if (!page_size)
                return -EINVAL;
 
-       log = ntfs_zalloc(sizeof(struct ntfs_log));
+       log = kzalloc(sizeof(struct ntfs_log), GFP_NOFS);
        if (!log)
                return -ENOMEM;
 
        log->ni = ni;
        log->l_size = l_size;
-       log->one_page_buf = ntfs_malloc(page_size);
+       log->one_page_buf = kmalloc(page_size, GFP_NOFS);
 
        if (!log->one_page_buf) {
                err = -ENOMEM;
                    sp->rhdr.sign == NTFS_CHKD_SIGNATURE) {
                        use_second_page = false;
                }
-               ntfs_free(sp);
+               kfree(sp);
        }
 
        if (use_second_page) {
-               ntfs_free(rst_info.r_page);
+               kfree(rst_info.r_page);
                memcpy(&rst_info, &rst_info2, sizeof(struct restart_info));
                rst_info2.r_page = NULL;
        }
 
 use_first_page:
-       ntfs_free(rst_info2.r_page);
+       kfree(rst_info2.r_page);
 
 check_restart_area:
        /* If the restart area is at offset 0, we want to write the second restart area first */
 
        log->current_avail = current_log_avail(log);
 
-       ra = ntfs_zalloc(log->restart_size);
+       ra = kzalloc(log->restart_size, GFP_NOFS);
        if (!ra) {
                err = -ENOMEM;
                goto out;
                goto out;
        }
 
-       trtbl = ntfs_memdup(rt, t32);
+       trtbl = kmemdup(rt, t32, GFP_NOFS);
        if (!trtbl) {
                err = -ENOMEM;
                goto out;
                goto out;
        }
 
-       dptbl = ntfs_memdup(rt, t32);
+       dptbl = kmemdup(rt, t32, GFP_NOFS);
        if (!dptbl) {
                err = -ENOMEM;
                goto out;
        t32 = lrh_length(lrh);
        rec_len -= t32;
 
-       attr_names = ntfs_memdup(Add2Ptr(lrh, t32), rec_len);
+       attr_names = kmemdup(Add2Ptr(lrh, t32), rec_len, GFP_NOFS);
 
        lcb_put(lcb);
        lcb = NULL;
                goto out;
        }
 
-       oatbl = ntfs_memdup(rt, t32);
+       oatbl = kmemdup(rt, t32, GFP_NOFS);
        if (!oatbl) {
                err = -ENOMEM;
                goto out;
                              sizeof(u64);
                } else {
                        t32 = log->clst_per_page;
-                       ntfs_free(dptbl);
+                       kfree(dptbl);
                        dptbl = init_rsttbl(struct_size(dp, page_lcns, t32),
                                            32);
                        if (!dptbl) {
 
                t16 = le16_to_cpu(lrh->undo_len);
                if (t16) {
-                       oe->ptr = ntfs_malloc(t16);
+                       oe->ptr = kmalloc(t16, GFP_NOFS);
                        if (!oe->ptr) {
                                err = -ENOMEM;
                                goto out;
                goto next_dirty_page;
        }
 
-       oa = ntfs_zalloc(sizeof(struct OpenAttr));
+       oa = kzalloc(sizeof(struct OpenAttr), GFP_NOFS);
        if (!oa) {
                err = -ENOMEM;
                goto out;
                attr = attr_create_nonres_log(sbi, oe->type, 0, oe->ptr,
                                              oe->name_len, 0);
                if (!attr) {
-                       ntfs_free(oa);
+                       kfree(oa);
                        err = -ENOMEM;
                        goto out;
                }
                goto fake_attr;
 
        t32 = le32_to_cpu(attr->size);
-       oa->attr = ntfs_memdup(attr, t32);
+       oa->attr = kmemdup(attr, t32, GFP_NOFS);
        if (!oa->attr)
                goto fake_attr;
 
                                 le64_to_cpu(attr->nres.evcn), svcn,
                                 Add2Ptr(attr, roff), t32 - roff);
                if (err < 0) {
-                       ntfs_free(oa->attr);
+                       kfree(oa->attr);
                        oa->attr = NULL;
                        goto fake_attr;
                }
 
 final_oe:
        if (oe->is_attr_name == 1)
-               ntfs_free(oe->ptr);
+               kfree(oe->ptr);
        oe->is_attr_name = 0;
        oe->ptr = oa;
        oe->name_len = attr->name_len;
        if (is_ro)
                goto out;
 
-       rh = ntfs_zalloc(log->page_size);
+       rh = kzalloc(log->page_size, GFP_NOFS);
        if (!rh) {
                err = -ENOMEM;
                goto out;
                err = ntfs_sb_write_run(sbi, &log->ni->file.run, log->page_size,
                                        rh, log->page_size);
 
-       ntfs_free(rh);
+       kfree(rh);
        if (err)
                goto out;
 
 out:
-       ntfs_free(rst);
+       kfree(rst);
        if (lcb)
                lcb_put(lcb);
 
                rno = ino_get(&oe->ref);
 
                if (oe->is_attr_name == 1) {
-                       ntfs_free(oe->ptr);
+                       kfree(oe->ptr);
                        oe->ptr = NULL;
                        continue;
                }
                        continue;
 
                run_close(&oa->run0);
-               ntfs_free(oa->attr);
+               kfree(oa->attr);
                if (oa->ni)
                        iput(&oa->ni->vfs_inode);
-               ntfs_free(oa);
+               kfree(oa);
        }
 
-       ntfs_free(trtbl);
-       ntfs_free(oatbl);
-       ntfs_free(dptbl);
-       ntfs_free(attr_names);
-       ntfs_free(rst_info.r_page);
+       kfree(trtbl);
+       kfree(oatbl);
+       kfree(dptbl);
+       kfree(attr_names);
+       kfree(rst_info.r_page);
 
-       ntfs_free(ra);
-       ntfs_free(log->one_page_buf);
+       kfree(ra);
+       kfree(log->one_page_buf);
 
        if (err)
                sbi->flags |= NTFS_FLAGS_NEED_REPLAY;
        else if (log->set_dirty)
                ntfs_set_state(sbi, NTFS_DIRTY_ERROR);
 
-       ntfs_free(log);
+       kfree(log);
 
        return err;
 }
 
 
        *size = t32 - SIZEOF_SECURITY_HDR;
 
-       p = ntfs_malloc(*size);
+       p = kmalloc(*size, GFP_NOFS);
        if (!p) {
                err = -ENOMEM;
                goto out;
        p = NULL;
 
 out:
-       ntfs_free(p);
+       kfree(p);
        fnd_put(fnd_sii);
        ni_unlock(ni);
 
        *security_id = SECURITY_ID_INVALID;
 
        /* Allocate a temporal buffer*/
-       d_security = ntfs_zalloc(aligned_sec_size);
+       d_security = kzalloc(aligned_sec_size, GFP_NOFS);
        if (!d_security)
                return -ENOMEM;
 
        fnd_put(fnd_sdh);
        mark_inode_dirty(&ni->vfs_inode);
        ni_unlock(ni);
-       ntfs_free(d_security);
+       kfree(d_security);
 
        return err;
 }
 
        if (end > 0x10000)
                goto next;
 
-       offs = ntfs_malloc(sizeof(u16) * nslots);
+       offs = kmalloc(sizeof(u16) * nslots, GFP_NOFS);
        if (!offs)
                goto next;
 
                u16 *ptr;
                int new_slots = ALIGN(2 * nslots, 8);
 
-               ptr = ntfs_malloc(sizeof(u16) * new_slots);
+               ptr = kmalloc(sizeof(u16) * new_slots, GFP_NOFS);
                if (ptr)
                        memcpy(ptr, offs, sizeof(u16) * max_idx);
-               ntfs_free(offs);
+               kfree(offs);
                offs = ptr;
                nslots = new_slots;
                if (!ptr)
        e = Add2Ptr(hdr, offs[fnd]);
 
 out1:
-       ntfs_free(offs);
+       kfree(offs);
 
        return e;
 #endif
        u16 fn;
        u32 eo;
 
-       r = ntfs_zalloc(sizeof(struct indx_node));
+       r = kzalloc(sizeof(struct indx_node), GFP_NOFS);
        if (!r)
                return ERR_PTR(-ENOMEM);
 
-       index = ntfs_zalloc(bytes);
+       index = kzalloc(bytes, GFP_NOFS);
        if (!index) {
-               ntfs_free(r);
+               kfree(r);
                return ERR_PTR(-ENOMEM);
        }
 
        err = ntfs_get_bh(ni->mi.sbi, &indx->alloc_run, vbo, bytes, &r->nb);
 
        if (err) {
-               ntfs_free(index);
-               ntfs_free(r);
+               kfree(index);
+               kfree(r);
                return ERR_PTR(err);
        }
 
        const struct INDEX_NAMES *name;
 
        if (!in) {
-               in = ntfs_zalloc(sizeof(struct indx_node));
+               in = kzalloc(sizeof(struct indx_node), GFP_NOFS);
                if (!in)
                        return -ENOMEM;
        } else {
 
        ib = in->index;
        if (!ib) {
-               ib = ntfs_malloc(bytes);
+               ib = kmalloc(bytes, GFP_NOFS);
                if (!ib) {
                        err = -ENOMEM;
                        goto out;
 
 out:
        if (ib != in->index)
-               ntfs_free(ib);
+               kfree(ib);
 
        if (*node != in) {
                nb_put(&in->nb);
-               ntfs_free(in);
+               kfree(in);
        }
 
        return err;
                    sizeof(struct NTFS_DE) + sizeof(u64)) {
                        if (n) {
                                fnd_pop(fnd);
-                               ntfs_free(n);
+                               kfree(n);
                        }
                        return -EINVAL;
                }
                /* Try next level */
                e = hdr_first_de(&n->index->ihdr);
                if (!e) {
-                       ntfs_free(n);
+                       kfree(n);
                        return -EINVAL;
                }
 
                /* Pop one level */
                if (n) {
                        fnd_pop(fnd);
-                       ntfs_free(n);
+                       kfree(n);
                }
 
                level = fnd->level;
        }
 
        /* Make a copy of root attribute to restore if error */
-       a_root = ntfs_memdup(attr, asize);
+       a_root = kmemdup(attr, asize, GFP_NOFS);
        if (!a_root) {
                err = -ENOMEM;
                goto out;
        if (!to_move) {
                re = NULL;
        } else {
-               re = ntfs_memdup(e0, to_move);
+               re = kmemdup(e0, to_move, GFP_NOFS);
                if (!re) {
                        err = -ENOMEM;
                        goto out;
                 * new entry classic case when mft record is 1K and index
                 * buffer 4K the problem should not occurs
                 */
-               ntfs_free(re);
+               kfree(re);
                indx_write(indx, ni, n, 0);
 
                put_indx_node(n);
        n = NULL;
 
 out1:
-       ntfs_free(re);
+       kfree(re);
        if (n)
                put_indx_node(n);
 
 out:
-       ntfs_free(a_root);
+       kfree(a_root);
        return err;
 }
 
                return -EINVAL;
 
        sp_size = le16_to_cpu(sp->size);
-       up_e = ntfs_malloc(sp_size + sizeof(u64));
+       up_e = kmalloc(sp_size + sizeof(u64), GFP_NOFS);
        if (!up_e)
                return -ENOMEM;
        memcpy(up_e, sp, sp_size);
        }
 
 out:
-       ntfs_free(up_e);
+       kfree(up_e);
 
        return err;
 }
        n = fnd->nodes[level];
        te = hdr_first_de(&n->index->ihdr);
        /* Copy the candidate entry into the replacement entry buffer. */
-       re = ntfs_malloc(le16_to_cpu(te->size) + sizeof(u64));
+       re = kmalloc(le16_to_cpu(te->size) + sizeof(u64), GFP_NOFS);
        if (!re) {
                err = -ENOMEM;
                goto out;
                                                              fnd)
                                    : indx_insert_into_root(indx, ni, re, e,
                                                            ctx, fnd);
-                       ntfs_free(re);
+                       kfree(re);
 
                        if (err)
                                goto out;
                 * as appropriate.
                 */
                e_size = le16_to_cpu(e->size);
-               me = ntfs_memdup(e, e_size);
+               me = kmemdup(e, e_size, GFP_NOFS);
                if (!me) {
                        err = -ENOMEM;
                        goto out;
                 * Find the spot the tree where we want to insert the new entry.
                 */
                err = indx_insert_entry(indx, ni, me, ctx, fnd);
-               ntfs_free(me);
+               kfree(me);
                if (err)
                        goto out;
 
 
        __le16 *rp_name;
        typeof(rp->SymbolicLinkReparseBuffer) *rs;
 
-       rp = ntfs_zalloc(ntfs_reparse_bytes(2 * size + 2));
+       rp = kzalloc(ntfs_reparse_bytes(2 * size + 2), GFP_NOFS);
        if (!rp)
                return ERR_PTR(-ENOMEM);
 
 
        return rp;
 out:
-       ntfs_free(rp);
+       kfree(rp);
        return ERR_PTR(err);
 }
 
 
 out2:
        __putname(new_de);
-       ntfs_free(rp);
+       kfree(rp);
 
 out1:
        if (err)
                        goto out;
                }
        } else {
-               rp = ntfs_malloc(i_size);
+               rp = kmalloc(i_size, GFP_NOFS);
                if (!rp) {
                        err = -ENOMEM;
                        goto out;
        /* Always set last zero */
        buffer[err] = 0;
 out:
-       ntfs_free(to_free);
+       kfree(to_free);
        return err;
 }
 
 
  */
 struct lznt *get_lznt_ctx(int level)
 {
-       struct lznt *r = ntfs_zalloc(level ? offsetof(struct lznt, hash)
-                                          : sizeof(struct lznt));
+       struct lznt *r = kzalloc(level ? offsetof(struct lznt, hash) :
+                                        sizeof(struct lznt), GFP_NOFS);
 
        if (r)
                r->std = !level;
 
 void fnd_clear(struct ntfs_fnd *fnd);
 static inline struct ntfs_fnd *fnd_get(void)
 {
-       return ntfs_zalloc(sizeof(struct ntfs_fnd));
+       return kzalloc(sizeof(struct ntfs_fnd), GFP_NOFS);
 }
 static inline void fnd_put(struct ntfs_fnd *fnd)
 {
        if (fnd) {
                fnd_clear(fnd);
-               ntfs_free(fnd);
+               kfree(fnd);
        }
 }
 void indx_clear(struct ntfs_index *idx);
 
 static inline struct runs_tree *run_alloc(void)
 {
-       return ntfs_zalloc(sizeof(struct runs_tree));
+       return kzalloc(sizeof(struct runs_tree), GFP_NOFS);
 }
 
 static inline void run_close(struct runs_tree *run)
 {
-       ntfs_vfree(run->runs);
+       kvfree(run->runs);
        memset(run, 0, sizeof(*run));
 }
 
 static inline void run_free(struct runs_tree *run)
 {
        if (run) {
-               ntfs_vfree(run->runs);
-               ntfs_free(run);
+               kvfree(run->runs);
+               kfree(run);
        }
 }
 
        if (!in)
                return;
 
-       ntfs_free(in->index);
+       kfree(in->index);
        nb_put(&in->nb);
-       ntfs_free(in);
+       kfree(in);
 }
 
 static inline void mi_clear(struct mft_inode *mi)
 {
        nb_put(&mi->nb);
-       ntfs_free(mi->mrec);
+       kfree(mi->mrec);
        mi->mrec = NULL;
 }
 
 
 int mi_get(struct ntfs_sb_info *sbi, CLST rno, struct mft_inode **mi)
 {
        int err;
-       struct mft_inode *m = ntfs_zalloc(sizeof(struct mft_inode));
+       struct mft_inode *m = kzalloc(sizeof(struct mft_inode), GFP_NOFS);
 
        if (!m)
                return -ENOMEM;
 
        err = mi_init(m, sbi, rno);
        if (err) {
-               ntfs_free(m);
+               kfree(m);
                return err;
        }
 
 void mi_put(struct mft_inode *mi)
 {
        mi_clear(mi);
-       ntfs_free(mi);
+       kfree(mi);
 }
 
 int mi_init(struct mft_inode *mi, struct ntfs_sb_info *sbi, CLST rno)
 {
        mi->sbi = sbi;
        mi->rno = rno;
-       mi->mrec = ntfs_malloc(sbi->record_size);
+       mi->mrec = kmalloc(sbi->record_size, GFP_NOFS);
        if (!mi->mrec)
                return -ENOMEM;
 
 
        run->count -= index;
 
        if (!run->count) {
-               ntfs_vfree(run->runs);
+               kvfree(run->runs);
                run->runs = NULL;
                run->allocated = 0;
        }
 
        /* Do not reallocate array 'runs'. Only free if possible */
        if (!index) {
-               ntfs_vfree(run->runs);
+               kvfree(run->runs);
                run->runs = NULL;
                run->allocated = 0;
        }
 
                        WARN_ON(!is_mft && bytes > NTFS3_RUN_MAX_BYTES);
 
-                       new_ptr = ntfs_vmalloc(bytes);
+                       new_ptr = kvmalloc(bytes, GFP_KERNEL);
 
                        if (!new_ptr)
                                return false;
                        memcpy(r + 1, run->runs + index,
                               sizeof(struct ntfs_run) * (run->count - index));
 
-                       ntfs_vfree(run->runs);
+                       kvfree(run->runs);
                        run->runs = new_ptr;
                        run->allocated = bytes;
 
 
 /* noinline to reduce binary size*/
 static noinline void put_ntfs(struct ntfs_sb_info *sbi)
 {
-       ntfs_free(sbi->new_rec);
-       ntfs_vfree(ntfs_put_shared(sbi->upcase));
-       ntfs_free(sbi->def_table);
+       kfree(sbi->new_rec);
+       kvfree(ntfs_put_shared(sbi->upcase));
+       kfree(sbi->def_table);
 
        wnd_close(&sbi->mft.bitmap);
        wnd_close(&sbi->used.bitmap);
        indx_clear(&sbi->security.index_sdh);
        indx_clear(&sbi->reparse.index_r);
        indx_clear(&sbi->objid.index_o);
-       ntfs_free(sbi->compress.lznt);
+       kfree(sbi->compress.lznt);
 #ifdef CONFIG_NTFS3_LZX_XPRESS
        xpress_free_decompressor(sbi->compress.xpress);
        lzx_free_decompressor(sbi->compress.lzx);
 #endif
        clear_mount_options(&sbi->options);
 
-       ntfs_free(sbi);
+       kfree(sbi);
 }
 
 static void ntfs_put_super(struct super_block *sb)
 
        sbi->used.bitmap.nbits = clusters;
 
-       rec = ntfs_zalloc(record_size);
+       rec = kzalloc(record_size, GFP_NOFS);
        if (!rec) {
                err = -ENOMEM;
                goto out;
 
        ref.high = 0;
 
-       sbi = ntfs_zalloc(sizeof(struct ntfs_sb_info));
+       sbi = kzalloc(sizeof(struct ntfs_sb_info), GFP_NOFS);
        if (!sbi)
                return -ENOMEM;
 
                goto out;
        }
        bytes = inode->i_size;
-       sbi->def_table = t = ntfs_malloc(bytes);
+       sbi->def_table = t = kmalloc(bytes, GFP_NOFS);
        if (!t) {
                err = -ENOMEM;
                goto out;
                goto out;
        }
 
-       sbi->upcase = upcase = ntfs_vmalloc(0x10000 * sizeof(short));
+       sbi->upcase = upcase = kvmalloc(0x10000 * sizeof(short), GFP_KERNEL);
        if (!upcase) {
                err = -ENOMEM;
                goto out;
        shared = ntfs_set_shared(upcase, 0x10000 * sizeof(short));
        if (shared && upcase != shared) {
                sbi->upcase = shared;
-               ntfs_vfree(upcase);
+               kvfree(upcase);
        }
 
        iput(inode);
 
                return -EFBIG;
 
        /* Allocate memory for packed Ea */
-       ea_p = ntfs_malloc(size + add_bytes);
+       ea_p = kmalloc(size + add_bytes, GFP_NOFS);
        if (!ea_p)
                return -ENOMEM;
 
        return 0;
 
 out:
-       ntfs_free(ea_p);
+       kfree(ea_p);
        *ea = NULL;
        return err;
 }
        }
 
 out:
-       ntfs_free(ea_all);
+       kfree(ea_all);
        return err ? err : ret;
 }
 
        err = 0;
 
 out:
-       ntfs_free(ea_all);
+       kfree(ea_all);
        if (!required)
                ni_unlock(ni);
 
                }
 
                if (!ea_all) {
-                       ea_all = ntfs_zalloc(add);
+                       ea_all = kzalloc(add, GFP_NOFS);
                        if (!ea_all) {
                                err = -ENOMEM;
                                goto out;
                ni_unlock(ni);
 
        run_close(&ea_run);
-       ntfs_free(ea_all);
+       kfree(ea_all);
 
        return err;
 }
                value = NULL;
        } else {
                size = posix_acl_xattr_size(acl->a_count);
-               value = ntfs_malloc(size);
+               value = kmalloc(size, GFP_NOFS);
                if (!value)
                        return -ENOMEM;
 
                set_cached_acl(inode, type, acl);
 
 out:
-       ntfs_free(value);
+       kfree(value);
 
        return err;
 }
                        err = sd_size;
                        memcpy(buffer, sd, sd_size);
                }
-               ntfs_free(sd);
+               kfree(sd);
                goto out;
        }