aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Streetman <ddstreet@ieee.org>2015-12-18 17:22:04 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2015-12-18 17:25:40 -0500
commit8bc8b228d076ae93398316f81eab35f3d12c0c4f (patch)
tree3337c11e0321875600a1018315c254f25b5ee72b
parent41a0c249cb8706a2efa1ab3d59466b23a27d0c8b (diff)
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: 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>
-rw-r--r--mm/zswap.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/mm/zswap.c b/mm/zswap.c
index 025f8dc723de..bf14508afd64 100644
--- a/mm/zswap.c
+++ b/mm/zswap.c
@@ -541,6 +541,7 @@ static struct zswap_pool *zswap_pool_last_get(void)
541 return last; 541 return last;
542} 542}
543 543
544/* type and compressor must be null-terminated */
544static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor) 545static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
545{ 546{
546 struct zswap_pool *pool; 547 struct zswap_pool *pool;
@@ -548,10 +549,9 @@ static struct zswap_pool *zswap_pool_find_get(char *type, char *compressor)
548 assert_spin_locked(&zswap_pools_lock); 549 assert_spin_locked(&zswap_pools_lock);
549 550
550 list_for_each_entry_rcu(pool, &zswap_pools, list) { 551 list_for_each_entry_rcu(pool, &zswap_pools, list) {
551 if (strncmp(pool->tfm_name, compressor, sizeof(pool->tfm_name))) 552 if (strcmp(pool->tfm_name, compressor))
552 continue; 553 continue;
553 if (strncmp(zpool_get_type(pool->zpool), type, 554 if (strcmp(zpool_get_type(pool->zpool), type))
554 sizeof(zswap_zpool_type)))
555 continue; 555 continue;
556 /* if we can't get it, it's about to be destroyed */ 556 /* if we can't get it, it's about to be destroyed */
557 if (!zswap_pool_get(pool)) 557 if (!zswap_pool_get(pool))