linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
@ 2022-10-25 15:34 Dan Carpenter
  2022-10-25 16:51 ` Rafał Miłecki
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Dan Carpenter @ 2022-10-25 15:34 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, kernel-janitors

On 64 bit systems, the highest 32 bits of the "offset" variable are
not initialized.  Also the existing code is not endian safe (it will
fail on big endian systems).  Change the type of "offset" to a u32.

Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/mtd/parsers/tplink_safeloader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
index 23584a477391..f601e7bd8627 100644
--- a/drivers/mtd/parsers/tplink_safeloader.c
+++ b/drivers/mtd/parsers/tplink_safeloader.c
@@ -23,8 +23,8 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
 	struct safeloader_cmn_header hdr;
 	struct device_node *np;
 	size_t bytes_read;
-	size_t offset;
 	size_t size;
+	u32 offset;
 	char *buf;
 	int err;
 
@@ -34,14 +34,14 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
 	else
 		np = of_get_child_by_name(np, "partitions");
 
-	if (of_property_read_u32(np, "partitions-table-offset", (u32 *)&offset)) {
+	if (of_property_read_u32(np, "partitions-table-offset", &offset)) {
 		pr_err("Failed to get partitions table offset\n");
 		goto err_put;
 	}
 
 	err = mtd_read(mtd, offset, sizeof(hdr), &bytes_read, (uint8_t *)&hdr);
 	if (err && !mtd_is_bitflip(err)) {
-		pr_err("Failed to read from %s at 0x%zx\n", mtd->name, offset);
+		pr_err("Failed to read from %s at 0x%x\n", mtd->name, offset);
 		goto err_put;
 	}
 
-- 
2.35.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
  2022-10-25 15:34 [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug Dan Carpenter
@ 2022-10-25 16:51 ` Rafał Miłecki
       [not found] ` <MN2PR17MB33758BC764511BB48B64192AB8319@MN2PR17MB3375.namprd17.prod.outlook.com>
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Rafał Miłecki @ 2022-10-25 16:51 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, kernel-janitors

On 25.10.2022 17:34, Dan Carpenter wrote:
> On 64 bit systems, the highest 32 bits of the "offset" variable are
> not initialized.  Also the existing code is not endian safe (it will
> fail on big endian systems).  Change the type of "offset" to a u32.
> 
> Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rafał Miłecki <rafal@milecki.pl>

Thanks


> ---
>   drivers/mtd/parsers/tplink_safeloader.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
> index 23584a477391..f601e7bd8627 100644
> --- a/drivers/mtd/parsers/tplink_safeloader.c
> +++ b/drivers/mtd/parsers/tplink_safeloader.c
> @@ -23,8 +23,8 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>   	struct safeloader_cmn_header hdr;
>   	struct device_node *np;
>   	size_t bytes_read;
> -	size_t offset;
>   	size_t size;
> +	u32 offset;
>   	char *buf;
>   	int err;
>   
> @@ -34,14 +34,14 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>   	else
>   		np = of_get_child_by_name(np, "partitions");
>   
> -	if (of_property_read_u32(np, "partitions-table-offset", (u32 *)&offset)) {
> +	if (of_property_read_u32(np, "partitions-table-offset", &offset)) {
>   		pr_err("Failed to get partitions table offset\n");
>   		goto err_put;
>   	}
>   
>   	err = mtd_read(mtd, offset, sizeof(hdr), &bytes_read, (uint8_t *)&hdr);
>   	if (err && !mtd_is_bitflip(err)) {
> -		pr_err("Failed to read from %s at 0x%zx\n", mtd->name, offset);
> +		pr_err("Failed to read from %s at 0x%x\n", mtd->name, offset);
>   		goto err_put;
>   	}
>   

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
       [not found] ` <MN2PR17MB33758BC764511BB48B64192AB8319@MN2PR17MB3375.namprd17.prod.outlook.com>
@ 2022-10-26  9:43   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2022-10-26  9:43 UTC (permalink / raw)
  To: Vanessa Page
  Cc: Rafał Miłecki, Miquel Raynal, Richard Weinberger,
	Vignesh Raghavendra, linux-mtd, kernel-janitors

On Tue, Oct 25, 2022 at 04:03:37PM +0000, Vanessa Page wrote:
> On its 64 dysfunctional delusional system

Hey Venessa,

I had been told you were removed from the linux-mtd@lists.infradead.org
list but I guess not.  I've sent you an unsubscribe email, if you just
click on the URL then you won't get these emails any more.

regards,
dan carpenter


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
  2022-10-25 15:34 [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug Dan Carpenter
  2022-10-25 16:51 ` Rafał Miłecki
       [not found] ` <MN2PR17MB33758BC764511BB48B64192AB8319@MN2PR17MB3375.namprd17.prod.outlook.com>
@ 2022-11-07 15:52 ` Miquel Raynal
  2022-11-07 16:01   ` Rafał Miłecki
  2022-11-07 16:22 ` Miquel Raynal
  3 siblings, 1 reply; 7+ messages in thread
From: Miquel Raynal @ 2022-11-07 15:52 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Rafał Miłecki, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, kernel-janitors

Hi Dan,

dan.carpenter@oracle.com wrote on Tue, 25 Oct 2022 18:34:24 +0300:

> On 64 bit systems, the highest 32 bits of the "offset" variable are
> not initialized.  Also the existing code is not endian safe (it will
> fail on big endian systems).  Change the type of "offset" to a u32.
> 
> Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/mtd/parsers/tplink_safeloader.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
> index 23584a477391..f601e7bd8627 100644
> --- a/drivers/mtd/parsers/tplink_safeloader.c
> +++ b/drivers/mtd/parsers/tplink_safeloader.c

I am sorry but I don't have this file in my tree, what kernel are you
using?

> @@ -23,8 +23,8 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>  	struct safeloader_cmn_header hdr;
>  	struct device_node *np;
>  	size_t bytes_read;
> -	size_t offset;
>  	size_t size;
> +	u32 offset;
>  	char *buf;
>  	int err;
>  
> @@ -34,14 +34,14 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>  	else
>  		np = of_get_child_by_name(np, "partitions");
>  
> -	if (of_property_read_u32(np, "partitions-table-offset", (u32 *)&offset)) {
> +	if (of_property_read_u32(np, "partitions-table-offset", &offset)) {
>  		pr_err("Failed to get partitions table offset\n");
>  		goto err_put;
>  	}
>  
>  	err = mtd_read(mtd, offset, sizeof(hdr), &bytes_read, (uint8_t *)&hdr);
>  	if (err && !mtd_is_bitflip(err)) {
> -		pr_err("Failed to read from %s at 0x%zx\n", mtd->name, offset);
> +		pr_err("Failed to read from %s at 0x%x\n", mtd->name, offset);
>  		goto err_put;
>  	}
>  


Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
  2022-11-07 15:52 ` Miquel Raynal
@ 2022-11-07 16:01   ` Rafał Miłecki
  2022-11-07 16:10     ` Miquel Raynal
  0 siblings, 1 reply; 7+ messages in thread
From: Rafał Miłecki @ 2022-11-07 16:01 UTC (permalink / raw)
  To: Miquel Raynal, Dan Carpenter
  Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, kernel-janitors

On 7.11.2022 16:52, Miquel Raynal wrote:
> Hi Dan,
> 
> dan.carpenter@oracle.com wrote on Tue, 25 Oct 2022 18:34:24 +0300:
> 
>> On 64 bit systems, the highest 32 bits of the "offset" variable are
>> not initialized.  Also the existing code is not endian safe (it will
>> fail on big endian systems).  Change the type of "offset" to a u32.
>>
>> Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> ---
>>   drivers/mtd/parsers/tplink_safeloader.c | 6 +++---
>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
>> index 23584a477391..f601e7bd8627 100644
>> --- a/drivers/mtd/parsers/tplink_safeloader.c
>> +++ b/drivers/mtd/parsers/tplink_safeloader.c
> 
> I am sorry but I don't have this file in my tree, what kernel are you
> using?

https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/log/?h=mtd/next
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/commit/?h=mtd/next&id=aec4d5f5ffd0f0092bd9dc21ea90e0bc237d4b74

(committer Miquel Raynal ;) )


>> @@ -23,8 +23,8 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>>   	struct safeloader_cmn_header hdr;
>>   	struct device_node *np;
>>   	size_t bytes_read;
>> -	size_t offset;
>>   	size_t size;
>> +	u32 offset;
>>   	char *buf;
>>   	int err;
>>   
>> @@ -34,14 +34,14 @@ static void *mtd_parser_tplink_safeloader_read_table(struct mtd_info *mtd)
>>   	else
>>   		np = of_get_child_by_name(np, "partitions");
>>   
>> -	if (of_property_read_u32(np, "partitions-table-offset", (u32 *)&offset)) {
>> +	if (of_property_read_u32(np, "partitions-table-offset", &offset)) {
>>   		pr_err("Failed to get partitions table offset\n");
>>   		goto err_put;
>>   	}
>>   
>>   	err = mtd_read(mtd, offset, sizeof(hdr), &bytes_read, (uint8_t *)&hdr);
>>   	if (err && !mtd_is_bitflip(err)) {
>> -		pr_err("Failed to read from %s at 0x%zx\n", mtd->name, offset);
>> +		pr_err("Failed to read from %s at 0x%x\n", mtd->name, offset);
>>   		goto err_put;
>>   	}
>>   

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
  2022-11-07 16:01   ` Rafał Miłecki
@ 2022-11-07 16:10     ` Miquel Raynal
  0 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2022-11-07 16:10 UTC (permalink / raw)
  To: Rafał Miłecki
  Cc: Dan Carpenter, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, kernel-janitors


rafal@milecki.pl wrote on Mon, 7 Nov 2022 17:01:04 +0100:

> On 7.11.2022 16:52, Miquel Raynal wrote:
> > Hi Dan,
> > 
> > dan.carpenter@oracle.com wrote on Tue, 25 Oct 2022 18:34:24 +0300:
> >   
> >> On 64 bit systems, the highest 32 bits of the "offset" variable are
> >> not initialized.  Also the existing code is not endian safe (it will
> >> fail on big endian systems).  Change the type of "offset" to a u32.
> >>
> >> Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
> >> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >> ---
> >>   drivers/mtd/parsers/tplink_safeloader.c | 6 +++---
> >>   1 file changed, 3 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/mtd/parsers/tplink_safeloader.c b/drivers/mtd/parsers/tplink_safeloader.c
> >> index 23584a477391..f601e7bd8627 100644
> >> --- a/drivers/mtd/parsers/tplink_safeloader.c
> >> +++ b/drivers/mtd/parsers/tplink_safeloader.c  
> > 
> > I am sorry but I don't have this file in my tree, what kernel are you
> > using?  
> 
> https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/log/?h=mtd/next
> https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/commit/?h=mtd/next&id=aec4d5f5ffd0f0092bd9dc21ea90e0bc237d4b74
> 
> (committer Miquel Raynal ;) )

Ah, I knew I was missing something: the right branch. :-)

Thanks,
Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

* Re: [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug
  2022-10-25 15:34 [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug Dan Carpenter
                   ` (2 preceding siblings ...)
  2022-11-07 15:52 ` Miquel Raynal
@ 2022-11-07 16:22 ` Miquel Raynal
  3 siblings, 0 replies; 7+ messages in thread
From: Miquel Raynal @ 2022-11-07 16:22 UTC (permalink / raw)
  To: Dan Carpenter, Rafał Miłecki
  Cc: Miquel Raynal, Richard Weinberger, Vignesh Raghavendra,
	linux-mtd, kernel-janitors

On Tue, 2022-10-25 at 15:34:24 UTC, Dan Carpenter wrote:
> On 64 bit systems, the highest 32 bits of the "offset" variable are
> not initialized.  Also the existing code is not endian safe (it will
> fail on big endian systems).  Change the type of "offset" to a u32.
> 
> Fixes: aec4d5f5ffd0 ("mtd: parsers: add TP-Link SafeLoader partitions table parser")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Rafał Miłecki <rafal@milecki.pl>

Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.

Miquel

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

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

end of thread, other threads:[~2022-11-07 16:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-25 15:34 [PATCH] mtd: parsers: tplink_safeloader: fix uninitialized variable bug Dan Carpenter
2022-10-25 16:51 ` Rafał Miłecki
     [not found] ` <MN2PR17MB33758BC764511BB48B64192AB8319@MN2PR17MB3375.namprd17.prod.outlook.com>
2022-10-26  9:43   ` Dan Carpenter
2022-11-07 15:52 ` Miquel Raynal
2022-11-07 16:01   ` Rafał Miłecki
2022-11-07 16:10     ` Miquel Raynal
2022-11-07 16:22 ` Miquel Raynal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).