linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: clombard@linux.vnet.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [bug report] cxl: Add guest-specific code
Date: Fri, 15 Jul 2016 00:53:52 +0300	[thread overview]
Message-ID: <20160714215352.GA19749@mwanda> (raw)

Hello Christophe Lombard,

The patch 14baf4d9c739: "cxl: Add guest-specific code" from Mar 4,
2016, leads to the following static checker warning:

	drivers/misc/cxl/guest.c:1115 cxl_guest_init_adapter()
	error: we previously assumed 'adapter->guest' could be null (see line 1114)

drivers/misc/cxl/guest.c
  1105  struct cxl *cxl_guest_init_adapter(struct device_node *np, struct platform_device *pdev)
  1106  {
  1107          struct cxl *adapter;
  1108          bool free = true;
  1109          int rc;
  1110  
  1111          if (!(adapter = cxl_alloc_adapter()))
  1112                  return ERR_PTR(-ENOMEM);
  1113  
  1114          if (!(adapter->guest = kzalloc(sizeof(struct cxl_guest), GFP_KERNEL))) {
  1115                  free_adapter(adapter);
                        ^^^^^^^^^^^^^^^^^^^^^
We can't call free_adapter() if adapter->guest is NULL.

  1116                  return ERR_PTR(-ENOMEM);
  1117          }


	drivers/misc/cxl/guest.c:919 afu_properties_look_ok()
	warn: unsigned 'afu->crs_len' is never less than zero.

drivers/misc/cxl/guest.c
   907  static int afu_properties_look_ok(struct cxl_afu *afu)
   908  {
   909          if (afu->pp_irqs < 0) {
   910                  dev_err(&afu->dev, "Unexpected per-process minimum interrupt value\n");
   911                  return -EINVAL;
   912          }
   913  
   914          if (afu->max_procs_virtualised < 1) {
   915                  dev_err(&afu->dev, "Unexpected max number of processes virtualised value\n");
   916                  return -EINVAL;
   917          }
   918  
   919          if (afu->crs_len < 0) {
                    ^^^^^^^^^^^^^^^^
Remove this test.  Unsigned is never less than zero.

   920                  dev_err(&afu->dev, "Unexpected configuration record size value\n");
   921                  return -EINVAL;
   922          }
   923  
   924          return 0;
   925  }


regards,
dan carpenter

             reply	other threads:[~2016-07-14 21:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-14 21:53 Dan Carpenter [this message]
2016-07-15  7:20 ` [PATCH] cxl: fix potential NULL dereference in free_adapter() Andrew Donnellan
2016-07-20  9:10   ` Michael Ellerman
2016-07-15  7:23 ` [bug report] cxl: Add guest-specific code Andrew Donnellan

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=20160714215352.GA19749@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=clombard@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.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;
as well as URLs for NNTP newsgroup(s).