Skip to contentSkip to conversation

patch "cb710: avoid NULL pointer subtraction" added to char-misc-linus

PATCH [email protected] 1 participant 1 message Oct 5, 2021

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

cb710: avoid NULL pointer subtraction

to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.

The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)

The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.

If you have any questions about this process, please let me know.

From 42641042c10c757fe10cc09088cf3f436cec5007 Mon Sep 17 00:00:00 2001
From: Arnd Bergmann <[email protected]>
Date: Mon, 27 Sep 2021 14:13:57 +0200
Subject: cb710: avoid NULL pointer subtraction

clang-14 complains about an unusual way of converting a pointer to an integer:

drivers/misc/cb710/sgbuf2.c:50:15: error: performing pointer subtraction with a null pointer has undefined behavior [-Werror,-Wnull-pointer-subtraction]

        return ((ptr - NULL) & 3) != 0;

Replace this with a normal cast to uintptr_t.

Fixes 5f5bac8272be ("mmc: Driver for CB710/720 memory card reader (MMC part)")
Cc stable <[email protected]>
---
 drivers/misc/cb710/sgbuf2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/misc/cb710/sgbuf2.c +1 -1
index e5a4ed3701eb..a798fad5f03c 100644
@@ -47,7 +47,7 @@ static inline bool needs_unaligned_copy(const void *ptr)
 #ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
 	return false;
 #else
-	return ((ptr - NULL) & 3) != 0;
+	return ((uintptr_t)ptr & 3) != 0;
 #endif
 }
 
Signature · 1 line
2.33.0