All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: thellstrom@vmware.com
Cc: dri-devel@lists.freedesktop.org
Subject: re: drm/vmwgfx: Fix compat shader namespace
Date: Wed, 9 Jul 2014 15:48:07 +0300	[thread overview]
Message-ID: <20140709124807.GA7707@mwanda> (raw)

Hello Thomas Hellstrom,

The patch 18e4a4669c50: "drm/vmwgfx: Fix compat shader namespace"
from Jun 9, 2014, leads to the following static checker warning:

	drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c:477 vmw_cmd_res_reloc_add()
	warn: missing error code here? 'kzalloc()' failed.

drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c
   468  
   469                  ret = vmw_resource_context_res_add(dev_priv, sw_context, res);
   470                  if (unlikely(ret != 0))
   471                          goto out_err;
   472                  node->staged_bindings =
   473                          kzalloc(sizeof(*node->staged_bindings), GFP_KERNEL);
   474                  if (node->staged_bindings == NULL) {
   475                          DRM_ERROR("Failed to allocate context binding "
   476                                    "information.\n");
   477                          goto out_err;

This should just be "return -ENOMEM;".  The goto is misleading because
you expect it to do something useful.

Soon checkpatch.pl will start complaining about the extra DRM_ERROR()
because kzalloc() has a more useful printk builtin and this just wastes
memory and makes the code more verbose.

Speaking of verbose, all the likely/unlikely annotations should be
removed.  If the code were more readable then the missing error code
would have been more noticeable.  This code is buggy because it is ugly;
there is a direct cause effect relationship.

   478                  }
   479                  INIT_LIST_HEAD(&node->staged_bindings->list);
   480          }
   481  
   482          if (p_val)
   483                  *p_val = node;
   484  
   485  out_err:
   486          return ret;
   487  }

regards,
dan carpenter

             reply	other threads:[~2014-07-09 12:48 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-09 12:48 Dan Carpenter [this message]
2014-07-09 21:31 ` drm/vmwgfx: Fix compat shader namespace Thomas Hellström
2014-07-10  9:33   ` Dan Carpenter
2014-07-10 22:14     ` Thomas Hellström
2014-07-11  8:43       ` Dan Carpenter

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=20140709124807.GA7707@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=thellstrom@vmware.com \
    /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.