All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
To: jroedel-l3A5Bk7waGM@public.gmane.org
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: re: iommu/amd: Implement dm_region call-backs
Date: Wed, 10 Jun 2015 18:39:20 +0300	[thread overview]
Message-ID: <20150610153920.GC10549@mwanda> (raw)

Hello Joerg Roedel,

The patch b61238c4a5e1: "iommu/amd: Implement dm_region call-backs"
from May 28, 2015, leads to the following static checker warning:

	drivers/iommu/amd_iommu.c:3153 amd_iommu_get_dm_regions()
	error: potential null dereference 'region'.  (kzalloc returns null)

drivers/iommu/amd_iommu.c
  3138  static void amd_iommu_get_dm_regions(struct device *dev,
  3139                                       struct list_head *head)
  3140  {
  3141          struct unity_map_entry *entry;
  3142          u16 devid;
  3143  
  3144          devid = get_device_id(dev);
  3145  
  3146          list_for_each_entry(entry, &amd_iommu_unity_map, list) {
  3147                  struct iommu_dm_region *region;
  3148  
  3149                  if (devid < entry->devid_start || devid > entry->devid_end)
  3150                          continue;
  3151  
  3152                  region = kzalloc(sizeof(*region), GFP_KERNEL);

No check here.  We may not care and in that case just ignore this
email.  Or add GFP_NOFAIL to silence the warning if you want.

  3153                  region->start = entry->address_start;
  3154                  region->length = entry->address_end - entry->address_start;
  3155                  if (entry->prot & IOMMU_PROT_IR)
  3156                          region->prot |= IOMMU_READ;
  3157                  if (entry->prot & IOMMU_PROT_IW)
  3158                          region->prot |= IOMMU_WRITE;
  3159  
  3160                  list_add_tail(&region->list, head);
  3161          }
  3162  }

regards,
dan carpenter

             reply	other threads:[~2015-06-10 15:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 15:39 Dan Carpenter [this message]
2015-06-11  7:43 ` iommu/amd: Implement dm_region call-backs Joerg Roedel
     [not found]   ` <20150611074327.GD16345-l3A5Bk7waGM@public.gmane.org>
2015-06-11  8:02     ` Dan Carpenter
2015-06-11  8:07       ` Joerg Roedel

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=20150610153920.GC10549@mwanda \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public.gmane.org \
    --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=jroedel-l3A5Bk7waGM@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.