Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e4573b05 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "zram: fix race condition while returning zram_entry refcount"

parents 0985a2a9 ea4e85ba
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -92,13 +92,14 @@ static unsigned long zram_dedup_put(struct zram *zram,
{
	struct zram_hash *hash;
	u32 checksum;
	unsigned long val;

	checksum = entry->checksum;
	hash = &zram->hash[checksum % zram->hash_size];

	spin_lock(&hash->lock);

	entry->refcount--;
	val = --entry->refcount;
	if (!entry->refcount)
		rb_erase(&entry->rb_node, &hash->rb_root);
	else
@@ -106,7 +107,7 @@ static unsigned long zram_dedup_put(struct zram *zram,

	spin_unlock(&hash->lock);

	return entry->refcount;
	return val;
}

static struct zram_entry *__zram_dedup_get(struct zram *zram,