Skip to content

Commit

Permalink
mm/zswap: change incorrect strncmp use to strcmp
Browse files Browse the repository at this point in the history
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: Dan Streetman <ddstreet@ieee.org>
Reported-by: Weijie Yang <weijie.yang@samsung.com>
Cc: Seth Jennings <sjennings@variantweb.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Dan Streetman authored and Linus Torvalds committed Dec 18, 2015
1 parent 41a0c24 commit 8bc8b22
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions mm/zswap.c
Original file line number Diff line number Diff line change
Expand Up @@ -541,17 +541,17 @@ static struct zswap_pool *zswap_pool_last_get(void)
return last;
}

/* type and compressor must be null-terminated */
static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
{
struct zswap_pool *pool;

assert_spin_locked(&zswap_pools_lock);

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;
if (strncmp(zpool_get_type(pool->zpool), type,
sizeof(zswap_zpool_type)))
if (strcmp(zpool_get_type(pool->zpool), type))
continue;
/* if we can't get it, it's about to be destroyed */
if (!zswap_pool_get(pool))
Expand Down

0 comments on commit 8bc8b22

Please sign in to comment.