[PATCH] LoongArch: take size of pointed value, not pointer

Haowen Bai posted 1 patch 1 year, 10 months ago
arch/loongarch/kernel/efi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] LoongArch: take size of pointed value, not pointer
Posted by Haowen Bai 1 year, 10 months ago
Sizeof a pointer-typed expression returns the size of the pointer, not
that of the pointed data.

Signed-off-by: Haowen Bai <baihaowen@meizu.com>
---
 arch/loongarch/kernel/efi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
index f9fdeb1ae358..f0e5d0feffc2 100644
--- a/arch/loongarch/kernel/efi.c
+++ b/arch/loongarch/kernel/efi.c
@@ -180,7 +180,7 @@ void __init efi_init(void)
 	if (!efi_system_table)
 		return;
 
-	efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(efi_systab));
+	efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
 	if (!efi_systab) {
 		pr_err("Can't find EFI system table.\n");
 		return;
-- 
2.7.4
Re: [PATCH] LoongArch: take size of pointed value, not pointer
Posted by Huacai Chen 1 year, 10 months ago
Hi, Haowen,

On Tue, May 24, 2022 at 10:52 AM Haowen Bai <baihaowen@meizu.com> wrote:
>
> Sizeof a pointer-typed expression returns the size of the pointer, not
> that of the pointed data.
Your patch is correct, but the original patch hasn't been upstream, I don't
know how to handle it.

>
> Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> ---
>  arch/loongarch/kernel/efi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
> index f9fdeb1ae358..f0e5d0feffc2 100644
> --- a/arch/loongarch/kernel/efi.c
> +++ b/arch/loongarch/kernel/efi.c
> @@ -180,7 +180,7 @@ void __init efi_init(void)
>         if (!efi_system_table)
>                 return;
>
> -       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(efi_systab));
> +       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
>         if (!efi_systab) {
>                 pr_err("Can't find EFI system table.\n");
>                 return;
> --
> 2.7.4
>
Re: [PATCH] LoongArch: take size of pointed value, not pointer
Posted by Huacai Chen 1 year, 10 months ago
On Tue, May 24, 2022 at 11:06 AM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Haowen,
>
> On Tue, May 24, 2022 at 10:52 AM Haowen Bai <baihaowen@meizu.com> wrote:
> >
> > Sizeof a pointer-typed expression returns the size of the pointer, not
> > that of the pointed data.
> Your patch is correct, but the original patch hasn't been upstream, I don't
> know how to handle it.
I've squash your patch to the original one and add a Co-developed-by:,
not sure it is the best solution. Thanks.

>
> >
> > Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> > ---
> >  arch/loongarch/kernel/efi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
> > index f9fdeb1ae358..f0e5d0feffc2 100644
> > --- a/arch/loongarch/kernel/efi.c
> > +++ b/arch/loongarch/kernel/efi.c
> > @@ -180,7 +180,7 @@ void __init efi_init(void)
> >         if (!efi_system_table)
> >                 return;
> >
> > -       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(efi_systab));
> > +       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
> >         if (!efi_systab) {
> >                 pr_err("Can't find EFI system table.\n");
> >                 return;
> > --
> > 2.7.4
> >
Re: [PATCH] LoongArch: take size of pointed value, not pointer
Posted by Huacai Chen 1 year, 10 months ago
Hi, Haowen,

On Tue, May 24, 2022 at 12:03 PM Huacai Chen <chenhuacai@kernel.org> wrote:
>
> On Tue, May 24, 2022 at 11:06 AM Huacai Chen <chenhuacai@kernel.org> wrote:
> >
> > Hi, Haowen,
> >
> > On Tue, May 24, 2022 at 10:52 AM Haowen Bai <baihaowen@meizu.com> wrote:
> > >
> > > Sizeof a pointer-typed expression returns the size of the pointer, not
> > > that of the pointed data.
> > Your patch is correct, but the original patch hasn't been upstream, I don't
> > know how to handle it.
> I've squash your patch to the original one and add a Co-developed-by:,
> not sure it is the best solution. Thanks.
I was suggested that a "Suggested-by" is suitable.
https://lore.kernel.org/lkml/CAAhV-H6k=xC-fDYnwsqSeoj7QPPn8RAcR+waQMa8yTs5J-XOSg@mail.gmail.com/T/#t

Huacai
>
> >
> > >
> > > Signed-off-by: Haowen Bai <baihaowen@meizu.com>
> > > ---
> > >  arch/loongarch/kernel/efi.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/loongarch/kernel/efi.c b/arch/loongarch/kernel/efi.c
> > > index f9fdeb1ae358..f0e5d0feffc2 100644
> > > --- a/arch/loongarch/kernel/efi.c
> > > +++ b/arch/loongarch/kernel/efi.c
> > > @@ -180,7 +180,7 @@ void __init efi_init(void)
> > >         if (!efi_system_table)
> > >                 return;
> > >
> > > -       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(efi_systab));
> > > +       efi_systab = (efi_system_table_t *)early_memremap_ro(efi_system_table, sizeof(*efi_systab));
> > >         if (!efi_systab) {
> > >                 pr_err("Can't find EFI system table.\n");
> > >                 return;
> > > --
> > > 2.7.4
> > >
Re: [PATCH] LoongArch: take size of pointed value, not pointer
Posted by Ard Biesheuvel 1 year, 10 months ago
On Tue, 24 May 2022 at 13:41, Huacai Chen <chenhuacai@kernel.org> wrote:
>
> Hi, Haowen,
>
> On Tue, May 24, 2022 at 12:03 PM Huacai Chen <chenhuacai@kernel.org> wrote:
> >
> > On Tue, May 24, 2022 at 11:06 AM Huacai Chen <chenhuacai@kernel.org> wrote:
> > >
> > > Hi, Haowen,
> > >
> > > On Tue, May 24, 2022 at 10:52 AM Haowen Bai <baihaowen@meizu.com> wrote:
> > > >
> > > > Sizeof a pointer-typed expression returns the size of the pointer, not
> > > > that of the pointed data.
> > > Your patch is correct, but the original patch hasn't been upstream, I don't
> > > know how to handle it.
> > I've squash your patch to the original one and add a Co-developed-by:,
> > not sure it is the best solution. Thanks.
> I was suggested that a "Suggested-by" is suitable.
> https://lore.kernel.org/lkml/CAAhV-H6k=xC-fDYnwsqSeoj7QPPn8RAcR+waQMa8yTs5J-XOSg@mail.gmail.com/T/#t
>

Finding and fixing mistakes is the normal review process, and not
every addressed comment needs to be reflected in the tags, even if the
contributor sent it as a separate patch. Adding 'Suggested-by' to the
entire patch falsely implies that the author of the bugfix suggested
the entire work, which is not desirable either.

In this case, the bugfix is a well-known anti-pattern which is not
specific to the introduced code. I don't think this warrants a tag
tbh.