]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
scsi: scsi_debug: Negate wrapped memcmp() result
authorXu Rao <raoxu@uniontech.com>
Mon, 3 Aug 2026 09:53:28 +0000 (17:53 +0800)
committerMartin K. Petersen (Oracle) <mkp@kernel.org>
Fri, 7 Aug 2026 16:14:19 +0000 (12:14 -0400)
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>
Link: https://patch.msgid.link/E5AD42E9C0E18633+20260803095328.3445311-1-raoxu@uniontech.com
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>
drivers/scsi/scsi_debug.c

index 64305133213259471e540a71daf688bb0e3a9df9..4fb2dc403962746753b9ea171ace567380408f4a 100644 (file)
@@ -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)