All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dheeraj Reddy Jonnalagadda <dheeraj.linuxdev@gmail.com>
To: minchan@kernel.org, senozhatsky@chromium.org
Cc: axboe@kernel.dk, linux-kernel@vger.kernel.org,
	linux-block@vger.kernel.org
Subject: Clarification on last_comp_len logic in zram_write_page
Date: Fri, 13 Dec 2024 12:49:26 +0530	[thread overview]
Message-ID: <Z1vf/ladGMjeGpfi@HOME-PC> (raw)

Dear Maintainers,

I am writing to seek clarification regarding the use of last_comp_len
variable in zram_write_page function. Specifically, Coverity has flagged 
the issue (CID 1602439) in zram/zram_drv.c

Link to the coverity issue:
https://scan7.scan.coverity.com/#/project-view/52337/11354?selectedIssue=1602439

Currently, last_comp_len is initialized to 0 but never updated within the
function. This renders the conditional block shown below as dead code.

	if (last_comp_len && (last_comp_len != comp_len)) {
    		zs_free(zram->mem_pool, handle);
    		handle = -ENOMEM;
	}

From the context, it appears that this variable might be intended to track the
compression length from a previous iteration for comparison purposes.

I would like to confirm the intended behavior here:

	1. Should last_comp_len be updated to comp_len after every compression
	 iteration to enable this comparison?

	2. Is this logic necessary for scenarios where compression lengths
	differ between iterations, or can this block be removed altogether?

To address this, I propose a fix where last_comp_len is updated after the
conditional block as shown below, ensuring it reflects the last compression
length:
	if (last_comp_len && (last_comp_len != comp_len)) {
    		zs_free(zram->mem_pool, handle);
    		andle = -ENOMEM;
	}
	last_comp_len = comp_len;

Could you please clarify whether this approach aligns with the intended
functionality of the code?

Thank you for your time and assistance.

-Dheeraj

             reply	other threads:[~2024-12-13  7:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  7:19 Dheeraj Reddy Jonnalagadda [this message]
2024-12-13  8:00 ` Clarification on last_comp_len logic in zram_write_page Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z1vf/ladGMjeGpfi@HOME-PC \
    --to=dheeraj.linuxdev@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=senozhatsky@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.