re: mm/shmem: turn shmem_alloc_page() into shmem_alloc_folio()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

Static analysis with clang scan-build found an issue in the following commit:

commit b0bb08b2d5f399369a906eff0287e64b531881d8
Author: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx>
Date:   Fri Apr 29 14:43:02 2022 -0700

    mm/shmem: turn shmem_alloc_page() into shmem_alloc_folio()


The issue is as follows:

#ifdef CONFIG_USERFAULTFD
int shmem_mfill_atomic_pte(struct mm_struct *dst_mm,
                           pmd_t *dst_pmd,
                           struct vm_area_struct *dst_vma,
                           unsigned long dst_addr,
                           unsigned long src_addr,
                           bool zeropage, bool wp_copy,
                           struct page **pagep)
{
        struct inode *inode = file_inode(dst_vma->vm_file);
        struct shmem_inode_info *info = SHMEM_I(inode);
        struct address_space *mapping = inode->i_mapping;
        gfp_t gfp = mapping_gfp_mask(mapping);
        pgoff_t pgoff = linear_page_index(dst_vma, dst_addr);
        void *page_kaddr;
        struct folio *folio;
        struct page *page;

        ^^ page is not intialized

        int ret;
        pgoff_t max_off;

        if (!shmem_inode_acct_block(inode, 1)) {
                /*
* We may have got a page, returned -ENOENT triggering a retry, * and now we find ourselves with -ENOMEM. Release the page, to
                 * avoid a BUG_ON in our caller.
                 */
                if (unlikely(*pagep)) {
                        put_page(*pagep);
                        *pagep = NULL;
                }
                return -ENOMEM;
        }

        if (!*pagep) {
                ret = -ENOMEM;
                if (!page)
                        goto out_unacct_blocks;

                ^^ page is being referenced but it has not been set


The commit in question removed the assignment to page:

        if (!*pagep) {
                ret = -ENOMEM;
-               page = shmem_alloc_page(gfp, info, pgoff);
                if (!page)
                        goto out_unacct_blocks;


Colin




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux