Commit 8bc8b228 authored by Dan Streetman's avatar Dan Streetman Committed by Linus Torvalds

mm/zswap: change incorrect strncmp use to strcmp

Change the use of strncmp in zswap_pool_find_get() to strcmp.

The use of strncmp is no longer correct, now that zswap_zpool_type is
not an array; sizeof() will return the size of a pointer, which isn't
the right length to compare.  We don't need to use strncmp anyway,
because the existing params and the passed in params are all guaranteed
to be null terminated, so strcmp should be used.
Signed-off-by: default avatarDan Streetman <ddstreet@ieee.org>
Reported-by: default avatarWeijie Yang <weijie.yang@samsung.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 41a0c249
...@@ -541,6 +541,7 @@ static struct zswap_pool *zswap_pool_last_get(void) ...@@ -541,6 +541,7 @@ static struct zswap_pool *zswap_pool_last_get(void)
return last; return last;
} }
/* type and compressor must be null-terminated */
static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
{ {
struct zswap_pool *pool; struct zswap_pool *pool;
...@@ -548,10 +549,9 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) ...@@ -548,10 +549,9 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
assert_spin_locked(&zswap_pools_lock); assert_spin_locked(&zswap_pools_lock);
list_for_each_entry_rcu(pool, &zswap_pools, list) { list_for_each_entry_rcu(pool, &zswap_pools, list) {
if (strncmp(pool->tfm_name, compressor, sizeof(pool->tfm_name))) if (strcmp(pool->tfm_name, compressor))
continue; continue;
if (strncmp(zpool_get_type(pool->zpool), type, if (strcmp(zpool_get_type(pool->zpool), type))
sizeof(zswap_zpool_type)))
continue; continue;
/* if we can't get it, it's about to be destroyed */ /* if we can't get it, it's about to be destroyed */
if (!zswap_pool_get(pool)) if (!zswap_pool_get(pool))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment