diff mbox series

fs/proc/kcore.c: Pass a pointer to virt_addr_valid()

Message ID 20220829131317.114007-1-linus.walleij@linaro.org (mailing list archive)
State New
Headers show
Series fs/proc/kcore.c: Pass a pointer to virt_addr_valid() | expand

Commit Message

Linus Walleij Aug. 29, 2022, 1:13 p.m. UTC
The virt_addr_valid() should be passed a pointer, the current
code passing a long unsigned int is just exploiting the
unintentional polymorphism of these calls being implemented
as preprocessor macros.

Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
---
 fs/proc/kcore.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Matthew Wilcox Aug. 29, 2022, 3:18 p.m. UTC | #1
On Mon, Aug 29, 2022 at 03:13:17PM +0200, Linus Walleij wrote:
> The virt_addr_valid() should be passed a pointer, the current
> code passing a long unsigned int is just exploiting the
> unintentional polymorphism of these calls being implemented
> as preprocessor macros.

Why do you think it's unintended polymorphism?  It looks to me
like polymorphism is absolutely intended.
Linus Walleij Aug. 29, 2022, 9:03 p.m. UTC | #2
On Mon, Aug 29, 2022 at 5:18 PM Matthew Wilcox <willy@infradead.org> wrote:
> On Mon, Aug 29, 2022 at 03:13:17PM +0200, Linus Walleij wrote:

> > The virt_addr_valid() should be passed a pointer, the current
> > code passing a long unsigned int is just exploiting the
> > unintentional polymorphism of these calls being implemented
> > as preprocessor macros.
>
> Why do you think it's unintended polymorphism?  It looks to me
> like polymorphism is absolutely intended.

Intended, maybe.
Desired, no:
https://lore.kernel.org/linux-mm/20220701160004.2ffff4e5ab59a55499f4c736@linux-foundation.org/

Strong typing is nice.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index dff921f7ca33..f358960b7a1f 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -200,7 +200,7 @@  kclist_add_private(unsigned long pfn, unsigned long nr_pages, void *arg)
 	ent->addr = (unsigned long)page_to_virt(p);
 	ent->size = nr_pages << PAGE_SHIFT;
 
-	if (!virt_addr_valid(ent->addr))
+	if (!virt_addr_valid((void *)ent->addr))
 		goto free_out;
 
 	/* cut not-mapped area. ....from ppc-32 code. */