public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: aik@ozlabs.ru
Cc: kvm@vger.kernel.org
Subject: [bug report] powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown
Date: Tue, 14 Mar 2017 16:39:22 +0300	[thread overview]
Message-ID: <20170314133922.GA31823@mwanda> (raw)

Hello Alexey Kardashevskiy,

The patch 4b6fad7097f8: "powerpc/mm/iommu, vfio/spapr: Put pages on
VFIO container shutdown" from Nov 30, 2016, leads to the following
static checker warning:

	drivers/vfio/vfio_iommu_spapr_tce.c:201 tce_iommu_register_pages()
	error: potential null dereference 'tcemem'.  (kzalloc returns null)

drivers/vfio/vfio_iommu_spapr_tce.c
   176  static long tce_iommu_register_pages(struct tce_container *container,
   177                  __u64 vaddr, __u64 size)
   178  {
   179          long ret = 0;
   180          struct mm_iommu_table_group_mem_t *mem = NULL;
   181          struct tce_iommu_prereg *tcemem;
   182          unsigned long entries = size >> PAGE_SHIFT;
   183  
   184          if ((vaddr & ~PAGE_MASK) || (size & ~PAGE_MASK) ||
   185                          ((vaddr + size) < vaddr))
   186                  return -EINVAL;
   187  
   188          mem = mm_iommu_find(container->mm, vaddr, entries);
   189          if (mem) {
   190                  list_for_each_entry(tcemem, &container->prereg_list, next) {
   191                          if (tcemem->mem == mem)
   192                                  return -EBUSY;
   193                  }
   194          }
   195  
   196          ret = mm_iommu_get(container->mm, vaddr, entries, &mem);
   197          if (ret)
   198                  return ret;
   199  
   200          tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Not checked.

   201          tcemem->mem = mem;
   202          list_add(&tcemem->next, &container->prereg_list);
   203  
   204          container->enabled = true;
   205  
   206          return 0;
   207  }


regards,
dan carpenter

                 reply	other threads:[~2017-03-14 13:39 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170314133922.GA31823@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=aik@ozlabs.ru \
    --cc=kvm@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox