smalloc: fix int truncation issue
authorJens Axboe <axboe@kernel.dk>
Fri, 2 Nov 2012 15:35:18 +0000 (16:35 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 2 Nov 2012 15:35:18 +0000 (16:35 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
smalloc.c
smalloc.h

index d0b6f1e1f0059fb266aac3334d078f36715fbacd..9f40f65a620afaf6881d01013c34e025192ee773 100644 (file)
--- a/smalloc.c
+++ b/smalloc.c
@@ -431,10 +431,13 @@ static void *smalloc_pool(struct pool *pool, unsigned int size)
        return ptr;
 }
 
        return ptr;
 }
 
-void *smalloc(unsigned int size)
+void *smalloc(size_t size)
 {
        unsigned int i;
 
 {
        unsigned int i;
 
+       if (size != (unsigned int) size)
+               return NULL;
+
        global_write_lock();
        i = last_pool;
 
        global_write_lock();
        i = last_pool;
 
index 6905c6a8c3c806a7ce20616452bb4b82f1fbfe89..f9a5e410fae79b570973a708c95f713912d8e40c 100644 (file)
--- a/smalloc.h
+++ b/smalloc.h
@@ -1,7 +1,7 @@
 #ifndef FIO_SMALLOC_H
 #define FIO_SMALLOC_H
 
 #ifndef FIO_SMALLOC_H
 #define FIO_SMALLOC_H
 
-extern void *smalloc(unsigned int);
+extern void *smalloc(size_t);
 extern void sfree(void *);
 extern char *smalloc_strdup(const char *);
 extern void sinit(void);
 extern void sfree(void *);
 extern char *smalloc_strdup(const char *);
 extern void sinit(void);