mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: David Airlie <airlied@linux.ie>, Ben Skeggs <bskeggs@redhat.com>,
	dri-devel@lists.freedesktop.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] drm/nouveau: usif_ioctl: ensure returns are initialized
Date: Wed,  1 Jul 2015 17:51:35 +0100	[thread overview]
Message-ID: <1435769495-2025-1-git-send-email-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Various usif_ioctl helper functions do not initialize the
return variable ret and some of the error handling return
paths just return garbage values that were on the stack (or
in a register).  I believe that in all the cases, the
initial ret variable should be set to -EINVAL and subsequent
paths through these helper functions set it appropriately
otherwise.

Found via static analysis using cppcheck:

[drivers/gpu/drm/nouveau/nouveau_usif.c:138]:
    (error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:179]:
    (error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:202]:
    (error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:241]:
    (error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:157]:
    (error) Uninitialized variable: ret
[drivers/gpu/drm/nouveau/nouveau_usif.c:288]:
    (error) Uninitialized variable: ret

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/gpu/drm/nouveau/nouveau_usif.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_usif.c b/drivers/gpu/drm/nouveau/nouveau_usif.c
index cb1182d..01b50a2 100644
--- a/drivers/gpu/drm/nouveau/nouveau_usif.c
+++ b/drivers/gpu/drm/nouveau/nouveau_usif.c
@@ -129,7 +129,7 @@ usif_notify_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		struct nvif_notify_req_v0 v0;
 	} *req;
 	struct usif_notify *ntfy;
-	int ret;
+	int ret = -EINVAL;
 
 	if (nvif_unpack(args->v0, 0, 0, true)) {
 		if (usif_notify_find(f, args->v0.index))
@@ -170,7 +170,7 @@ usif_notify_del(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		struct nvif_ioctl_ntfy_del_v0 v0;
 	} *args = data;
 	struct usif_notify *ntfy;
-	int ret;
+	int ret = -EINVAL;
 
 	if (nvif_unpack(args->v0, 0, 0, true)) {
 		if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -193,7 +193,7 @@ usif_notify_get(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		struct nvif_ioctl_ntfy_del_v0 v0;
 	} *args = data;
 	struct usif_notify *ntfy;
-	int ret;
+	int ret = -EINVAL;
 
 	if (nvif_unpack(args->v0, 0, 0, true)) {
 		if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -232,7 +232,7 @@ usif_notify_put(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		struct nvif_ioctl_ntfy_put_v0 v0;
 	} *args = data;
 	struct usif_notify *ntfy;
-	int ret;
+	int ret = -EINVAL;
 
 	if (nvif_unpack(args->v0, 0, 0, true)) {
 		if (!(ntfy = usif_notify_find(f, args->v0.index)))
@@ -269,7 +269,7 @@ usif_object_new(struct drm_file *f, void *data, u32 size, void *argv, u32 argc)
 		struct nvif_ioctl_new_v0 v0;
 	} *args = data;
 	struct usif_object *object;
-	int ret;
+	int ret = -EINVAL;
 
 	if (!(object = kmalloc(sizeof(*object), GFP_KERNEL)))
 		return -ENOMEM;
-- 
2.1.4


             reply	other threads:[~2015-07-01 16:52 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-01 16:51 Colin King [this message]
2015-07-01 16:56 ` Ilia Mirkin
2015-07-01 17:12   ` Emil Velikov
2015-07-01 17:18     ` Colin Ian King
2015-07-01 17:37       ` Ilia Mirkin
2015-07-01 17:59         ` Emil Velikov
2015-07-01 18:06           ` Ilia Mirkin

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=1435769495-2025-1-git-send-email-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=airlied@linux.ie \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@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

all inboxes | Powered by JetHome®