All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch()
@ 2026-06-30 13:39 Md Shofiqul Islam
  2026-06-30 14:29 ` Ian Ray
  0 siblings, 1 reply; 5+ messages in thread
From: Md Shofiqul Islam @ 2026-06-30 13:39 UTC (permalink / raw)
  To: u-boot; +Cc: ian.ray, HuanWang, Md Shofiqul Islam

errloc stores bit positions of errors returned by decode_bch().
The maximum number of correctable errors is ecc_bits, so errloc
must have ecc_bits entries.  The array was allocated with data_length
entries instead, which is the number of EEPROM data bytes -- orders
of magnitude larger than needed and incorrect.

Fixes: b418dfe16e62 ("board: ge: make VPD code common")
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
 board/ge/common/vpd_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index 2422db38013..b3f9e96615d 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -66,7 +66,7 @@ static int verify_bch(int ecc_bits, unsigned int prim_poly, u8 *data,
 		return -1;
 	}
 
-	unsigned int *errloc = (unsigned int *)calloc(data_length,
+	unsigned int *errloc = (unsigned int *)calloc(ecc_bits,
 						      sizeof(unsigned int));
 	int errors = decode_bch(bch, data, data_length, ecc, NULL, NULL,
 				errloc);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch()
  2026-06-30 13:39 Md Shofiqul Islam
@ 2026-06-30 14:29 ` Ian Ray
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Ray @ 2026-06-30 14:29 UTC (permalink / raw)
  To: Md Shofiqul Islam; +Cc: u-boot, HuanWang

On Tue, Jun 30, 2026 at 04:39:39PM +0300, Md Shofiqul Islam wrote:
> errloc stores bit positions of errors returned by decode_bch().
> The maximum number of correctable errors is ecc_bits, so errloc
> must have ecc_bits entries.  The array was allocated with data_length
> entries instead, which is the number of EEPROM data bytes -- orders
> of magnitude larger than needed and incorrect.

Good catch, thanks for fixing this.

> 
> Fixes: b418dfe16e62 ("board: ge: make VPD code common")
> Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>

Reviewed-by: Ian Ray <ian.ray@gehealthcare.com>

> ---
>  board/ge/common/vpd_reader.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
> index 2422db38013..b3f9e96615d 100644
> --- a/board/ge/common/vpd_reader.c
> +++ b/board/ge/common/vpd_reader.c
> @@ -66,7 +66,7 @@ static int verify_bch(int ecc_bits, unsigned int prim_poly, u8 *data,
>                 return -1;
>         }
> 
> -       unsigned int *errloc = (unsigned int *)calloc(data_length,
> +       unsigned int *errloc = (unsigned int *)calloc(ecc_bits,
>                                                       sizeof(unsigned int));
>         int errors = decode_bch(bch, data, data_length, ecc, NULL, NULL,
>                                 errloc);
> --
> 2.51.1
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch()
@ 2026-06-30 15:06 Md Shofiqul Islam
  0 siblings, 0 replies; 5+ messages in thread
From: Md Shofiqul Islam @ 2026-06-30 15:06 UTC (permalink / raw)
  To: ian.ray; +Cc: u-boot, HuanWang

On Mon, Jun 30, 2026, Ian Ray wrote:
> Good catch, thanks for fixing this.
> Reviewed-by: Ian Ray <ian.ray@gehealthcare.com>

Thank you for the review, Ian.

Regards,
Md Shofiqul Islam

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch()
@ 2026-07-03 12:35 Md Shofiqul Islam
  0 siblings, 0 replies; 5+ messages in thread
From: Md Shofiqul Islam @ 2026-07-03 12:35 UTC (permalink / raw)
  To: u-boot; +Cc: trini, fberder, ian.ray, Md Shofiqul Islam

errloc stores bit positions of errors returned by decode_bch().
The maximum number of correctable errors is ecc_bits, so errloc
must have ecc_bits entries.  The array was allocated with data_length
entries instead, which is the number of EEPROM data bytes -- orders
of magnitude larger than needed and incorrect.

Fixes: b418dfe16e62 ("board: ge: make VPD code common")
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
 board/ge/common/vpd_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index 2422db38013..b3f9e96615d 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -66,7 +66,7 @@ static int verify_bch(int ecc_bits, unsigned int prim_poly, u8 *data,
 		return -1;
 	}
 
-	unsigned int *errloc = (unsigned int *)calloc(data_length,
+	unsigned int *errloc = (unsigned int *)calloc(ecc_bits,
 						      sizeof(unsigned int));
 	int errors = decode_bch(bch, data, data_length, ecc, NULL, NULL,
 				errloc);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch()
@ 2026-07-05 10:08 Md Shofiqul Islam
  0 siblings, 0 replies; 5+ messages in thread
From: Md Shofiqul Islam @ 2026-07-05 10:08 UTC (permalink / raw)
  To: u-boot; +Cc: Tom Rini, Francois Berder, Md Shofiqul Islam

errloc stores bit positions of errors returned by decode_bch().
The maximum number of correctable errors is ecc_bits, so errloc
must have ecc_bits entries.  The array was allocated with data_length
entries instead, which is the number of EEPROM data bytes -- orders
of magnitude larger than needed and incorrect.

Fixes: b418dfe16e62 ("board: ge: make VPD code common")
Signed-off-by: Md Shofiqul Islam <shofiqtest@gmail.com>
---
 board/ge/common/vpd_reader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/ge/common/vpd_reader.c b/board/ge/common/vpd_reader.c
index 2422db38013..b3f9e96615d 100644
--- a/board/ge/common/vpd_reader.c
+++ b/board/ge/common/vpd_reader.c
@@ -66,7 +66,7 @@ static int verify_bch(int ecc_bits, unsigned int prim_poly, u8 *data,
 		return -1;
 	}
 
-	unsigned int *errloc = (unsigned int *)calloc(data_length,
+	unsigned int *errloc = (unsigned int *)calloc(ecc_bits,
 						      sizeof(unsigned int));
 	int errors = decode_bch(bch, data, data_length, ecc, NULL, NULL,
 				errloc);
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-05 12:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-30 15:06 [PATCH] ge: common: vpd_reader: fix errloc array size in verify_bch() Md Shofiqul Islam
  -- strict thread matches above, loose matches on Subject: below --
2026-07-05 10:08 Md Shofiqul Islam
2026-07-03 12:35 Md Shofiqul Islam
2026-06-30 13:39 Md Shofiqul Islam
2026-06-30 14:29 ` Ian Ray

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.