Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: raoxu <raoxu@uniontech.com>, James.Bottomley@HansenPartnership.com
Cc: martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] scsi: scsi_debug: negate wrapped memcmp() result
Date: Mon, 3 Aug 2026 13:54:00 +0100	[thread overview]
Message-ID: <70563a46-220f-47bf-b3de-26e8e37eb0bd@oracle.com> (raw)
In-Reply-To: <E5AD42E9C0E18633+20260803095328.3445311-1-raoxu@uniontech.com>

On 03/08/2026 10:53, raoxu wrote:
> From: Xu Rao <raoxu@uniontech.com>
> 
> comp_write_worker() returns true when the compared data matches.
> memcmp() returns zero for equal data and non-zero for different data, so
> its result must be negated before it is stored in a bool.
> 
> The first segment already uses !memcmp(), but the wrapped segment uses
> memcmp() directly, reversing the match result. Use !memcmp() there as
> well.
> 
> Fixes: 38d5c8336e60 ("scsi_debug: add Report supported opcodes+tmfs; Compare and write")
> Cc: stable@vger.kernel.org
> Signed-off-by: Xu Rao <raoxu@uniontech.com>

Reviewed-by: John Garry <john.g.garry@oracle.com>

> ---
>   drivers/scsi/scsi_debug.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 9d1c9c41d0f9..a5911482fc44 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4310,8 +4310,8 @@ static bool comp_write_worker(struct sdeb_store_info *sip, u64 lba, u32 num,
>   	if (!res)
>   		return res;
>   	if (rest)
> -		res = memcmp(fsp, arr + ((num - rest) * lb_size),
> -			     rest * lb_size);
> +		res = !memcmp(fsp, arr + ((num - rest) * lb_size),
> +			      rest * lb_size);
>   	if (!res)
>   		return res;
>   	if (compare_only)
> --
> 2.50.1
> 
> 


      parent reply	other threads:[~2026-08-03 12:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03  9:53 [PATCH] scsi: scsi_debug: negate wrapped memcmp() result raoxu
2026-08-03 10:08 ` sashiko-bot
2026-08-03 12:54 ` John Garry [this message]

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=70563a46-220f-47bf-b3de-26e8e37eb0bd@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=raoxu@uniontech.com \
    --cc=stable@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox