Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752865AbbGAQwE (ORCPT ); Wed, 1 Jul 2015 12:52:04 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:57959 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752268AbbGAQvq (ORCPT ); Wed, 1 Jul 2015 12:51:46 -0400 From: Colin King To: David Airlie , Ben Skeggs , 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 Message-Id: <1435769495-2025-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 2.1.4 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3129 Lines: 87 From: Colin Ian King 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 --- 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/