drm/nouveau/nvif: return null pointers on failure, in addition to ret != 0
authorBen Skeggs <bskeggs@redhat.com>
Tue, 12 Aug 2014 12:56:09 +0000 (22:56 +1000)
committerBen Skeggs <bskeggs@redhat.com>
Thu, 14 Aug 2014 21:58:39 +0000 (07:58 +1000)
Reported by Coverity.  The intention is that the return value is
checked, but let's be more paranoid and make it extremely obvious
if something forgets to.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
drivers/gpu/drm/nouveau/nvif/notify.c
drivers/gpu/drm/nouveau/nvif/object.c

index 7e03cdd17827045aba1dd9e22d4e364067a4f368..0898c3155292c54453df568921e546d59bb3db4f 100644 (file)
@@ -237,8 +237,10 @@ nvif_notify_new(struct nvif_object *object, int (*func)(struct nvif_notify *),
        if (notify) {
                int ret = nvif_notify_init(object, nvif_notify_del, func, work,
                                           type, data, size, reply, notify);
-               if (ret)
+               if (ret) {
                        kfree(notify);
+                       notify = NULL;
+               }
                *pnotify = notify;
                return ret;
        }
index b0c82206ece204b649a2dad207b6faea405b05c6..dd85b56f6aa502a9ba65dcb9d9e9b2e61da7f664 100644 (file)
@@ -275,8 +275,10 @@ nvif_object_new(struct nvif_object *parent, u32 handle, u32 oclass,
        if (object) {
                int ret = nvif_object_init(parent, nvif_object_del, handle,
                                           oclass, data, size, object);
-               if (ret)
+               if (ret) {
                        kfree(object);
+                       object = NULL;
+               }
                *pobject = object;
                return ret;
        }