util: fput files refs in reverse order
authorDjalal Harouni <tixxdz@opendz.org>
Mon, 20 Oct 2014 20:28:42 +0000 (21:28 +0100)
committerDjalal Harouni <tixxdz@opendz.org>
Mon, 20 Oct 2014 20:28:42 +0000 (21:28 +0100)
Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
util.c

diff --git a/util.c b/util.c
index 56846ad23e4e567a0408f84b001e384f6f1ca626..d97b9d81f3e6793e6644ef9df76b4fb771caaac8 100644 (file)
--- a/util.c
+++ b/util.c
@@ -94,12 +94,12 @@ int kdbus_negotiate_flags(u64 flags, void __user *buf, off_t offset, u64 valid)
  */
 void kdbus_fput_files(struct file **files, unsigned int count)
 {
-       unsigned int i;
+       int i;
 
        if (!files)
                return;
 
-       for (i = 0; i < count; i++)
+       for (i = count - 1; i >= 0; i--)
                if (files[i]) {
                        fput(files[i]);
                        files[i] = NULL;