greybus: fix a leak on error in gb_module_create()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 14 Oct 2016 19:18:21 +0000 (22:18 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 24 Oct 2016 13:51:00 +0000 (15:51 +0200)
We should release ->interfaces[0] as well.

Fixes: b15d97d77017 ("greybus: core: add module abstraction")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/greybus/module.c

index 69f67ddbd4a364d00fe31932a15c773599eb8851..660b4674a76f584aa8a426abffc595d05051659c 100644 (file)
@@ -127,7 +127,7 @@ struct gb_module *gb_module_create(struct gb_host_device *hd, u8 module_id,
        return module;
 
 err_put_interfaces:
-       for (--i; i > 0; --i)
+       for (--i; i >= 0; --i)
                gb_interface_put(module->interfaces[i]);
 
        put_device(&module->dev);