linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] of: unittest: fix warning on PowerPC frame size warning
@ 2021-12-10 18:46 Jim Quinlan
  2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
  0 siblings, 1 reply; 6+ messages in thread
From: Jim Quinlan @ 2021-12-10 18:46 UTC (permalink / raw)
  To: Christoph Hellwig, bcm-kernel-feedback-list, jim2101024, james.quinlan
  Cc: open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list,
	Mathieu Poirier

v2 -- Fix memory leak (Florian).

v1 -- Original.

Jim Quinlan (1):
  of: unittest: fix warning on PowerPC frame size warning

 drivers/of/unittest.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)


base-commit: c741e49150dbb0c0aebe234389f4aa8b47958fa8
-- 
2.17.1


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

* [PATCH v2 1/1] of: unittest: fix warning on PowerPC frame size warning
  2021-12-10 18:46 [PATCH v2 0/1] of: unittest: fix warning on PowerPC frame size warning Jim Quinlan
@ 2021-12-10 18:46 ` Jim Quinlan
  2021-12-12 22:47   ` Frank Rowand
                     ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Jim Quinlan @ 2021-12-10 18:46 UTC (permalink / raw)
  To: Christoph Hellwig, bcm-kernel-feedback-list, jim2101024, james.quinlan
  Cc: Rob Herring, Frank Rowand, Mathieu Poirier,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

The struct device variable "dev_bogus" was triggering this warning
on a PowerPC build:

    drivers/of/unittest.c: In function 'of_unittest_dma_ranges_one.constprop':
    [...] >> The frame size of 1424 bytes is larger than 1024 bytes
             [-Wframe-larger-than=]

This variable is now dynamically allocated.

Fixes: e0d072782c734 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
---
 drivers/of/unittest.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 481ba8682ebf..02c5cd06ad19 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -911,11 +911,18 @@ static void __init of_unittest_dma_ranges_one(const char *path,
 	if (!rc) {
 		phys_addr_t	paddr;
 		dma_addr_t	dma_addr;
-		struct device	dev_bogus;
+		struct device	*dev_bogus;
 
-		dev_bogus.dma_range_map = map;
-		paddr = dma_to_phys(&dev_bogus, expect_dma_addr);
-		dma_addr = phys_to_dma(&dev_bogus, expect_paddr);
+		dev_bogus = kzalloc(sizeof(struct device), GFP_KERNEL);
+		if (!dev_bogus) {
+			unittest(0, "kzalloc() failed\n");
+			kfree(map);
+			return;
+		}
+
+		dev_bogus->dma_range_map = map;
+		paddr = dma_to_phys(dev_bogus, expect_dma_addr);
+		dma_addr = phys_to_dma(dev_bogus, expect_paddr);
 
 		unittest(paddr == expect_paddr,
 			 "of_dma_get_range: wrong phys addr %pap (expecting %llx) on node %pOF\n",
@@ -925,6 +932,7 @@ static void __init of_unittest_dma_ranges_one(const char *path,
 			 &dma_addr, expect_dma_addr, np);
 
 		kfree(map);
+		kfree(dev_bogus);
 	}
 	of_node_put(np);
 #endif
-- 
2.17.1


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

* Re: [PATCH v2 1/1] of: unittest: fix warning on PowerPC frame size warning
  2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
@ 2021-12-12 22:47   ` Frank Rowand
  2021-12-13  7:24   ` Christoph Hellwig
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Frank Rowand @ 2021-12-12 22:47 UTC (permalink / raw)
  To: Jim Quinlan, Christoph Hellwig, bcm-kernel-feedback-list,
	james.quinlan, Rob Herring, Frank Rowand
  Cc: Mathieu Poirier,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

moved the file's maintainers from the "cc:" list to the "to:" list

review comments below


On 12/10/21 1:46 PM, Jim Quinlan wrote:
> The struct device variable "dev_bogus" was triggering this warning
> on a PowerPC build:
> 
>     drivers/of/unittest.c: In function 'of_unittest_dma_ranges_one.constprop':
>     [...] >> The frame size of 1424 bytes is larger than 1024 bytes
>              [-Wframe-larger-than=]
> 
> This variable is now dynamically allocated.

A side effect of the change is that dev_bogus is initialized to all
zeros instead of containing random data from the stack.

> 
> Fixes: e0d072782c734 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> ---
>  drivers/of/unittest.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
> index 481ba8682ebf..02c5cd06ad19 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -911,11 +911,18 @@ static void __init of_unittest_dma_ranges_one(const char *path,
>  	if (!rc) {
>  		phys_addr_t	paddr;
>  		dma_addr_t	dma_addr;
> -		struct device	dev_bogus;
> +		struct device	*dev_bogus;
>  
> -		dev_bogus.dma_range_map = map;
> -		paddr = dma_to_phys(&dev_bogus, expect_dma_addr);
> -		dma_addr = phys_to_dma(&dev_bogus, expect_paddr);
> +		dev_bogus = kzalloc(sizeof(struct device), GFP_KERNEL);
> +		if (!dev_bogus) {
> +			unittest(0, "kzalloc() failed\n");
> +			kfree(map);
> +			return;
> +		}
> +
> +		dev_bogus->dma_range_map = map;
> +		paddr = dma_to_phys(dev_bogus, expect_dma_addr);
> +		dma_addr = phys_to_dma(dev_bogus, expect_paddr);
>  
>  		unittest(paddr == expect_paddr,
>  			 "of_dma_get_range: wrong phys addr %pap (expecting %llx) on node %pOF\n",
> @@ -925,6 +932,7 @@ static void __init of_unittest_dma_ranges_one(const char *path,
>  			 &dma_addr, expect_dma_addr, np);
>  
>  		kfree(map);
> +		kfree(dev_bogus);
>  	}
>  	of_node_put(np);
>  #endif
> 

Reviewed-by: Frank Rowand <frank.rowand@sony.com>

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

* Re: [PATCH v2 1/1] of: unittest: fix warning on PowerPC frame size warning
  2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
  2021-12-12 22:47   ` Frank Rowand
@ 2021-12-13  7:24   ` Christoph Hellwig
  2021-12-13 18:12   ` Florian Fainelli
  2021-12-15 19:54   ` Rob Herring
  3 siblings, 0 replies; 6+ messages in thread
From: Christoph Hellwig @ 2021-12-13  7:24 UTC (permalink / raw)
  To: Jim Quinlan
  Cc: Christoph Hellwig, bcm-kernel-feedback-list, james.quinlan,
	Rob Herring, Frank Rowand, Mathieu Poirier,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

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

* Re: [PATCH v2 1/1] of: unittest: fix warning on PowerPC frame size warning
  2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
  2021-12-12 22:47   ` Frank Rowand
  2021-12-13  7:24   ` Christoph Hellwig
@ 2021-12-13 18:12   ` Florian Fainelli
  2021-12-15 19:54   ` Rob Herring
  3 siblings, 0 replies; 6+ messages in thread
From: Florian Fainelli @ 2021-12-13 18:12 UTC (permalink / raw)
  To: Jim Quinlan, Christoph Hellwig, bcm-kernel-feedback-list, james.quinlan
  Cc: Rob Herring, Frank Rowand, Mathieu Poirier,
	open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE, open list

On 12/10/21 10:46 AM, Jim Quinlan wrote:
> The struct device variable "dev_bogus" was triggering this warning
> on a PowerPC build:
> 
>     drivers/of/unittest.c: In function 'of_unittest_dma_ranges_one.constprop':
>     [...] >> The frame size of 1424 bytes is larger than 1024 bytes
>              [-Wframe-larger-than=]
> 
> This variable is now dynamically allocated.
> 
> Fixes: e0d072782c734 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 1/1] of: unittest: fix warning on PowerPC frame size warning
  2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
                     ` (2 preceding siblings ...)
  2021-12-13 18:12   ` Florian Fainelli
@ 2021-12-15 19:54   ` Rob Herring
  3 siblings, 0 replies; 6+ messages in thread
From: Rob Herring @ 2021-12-15 19:54 UTC (permalink / raw)
  To: Jim Quinlan
  Cc: Frank Rowand, Christoph Hellwig, Rob Herring, james.quinlan,
	devicetree, bcm-kernel-feedback-list, Mathieu Poirier,
	linux-kernel

On Fri, 10 Dec 2021 13:46:35 -0500, Jim Quinlan wrote:
> The struct device variable "dev_bogus" was triggering this warning
> on a PowerPC build:
> 
>     drivers/of/unittest.c: In function 'of_unittest_dma_ranges_one.constprop':
>     [...] >> The frame size of 1424 bytes is larger than 1024 bytes
>              [-Wframe-larger-than=]
> 
> This variable is now dynamically allocated.
> 
> Fixes: e0d072782c734 ("dma-mapping: introduce DMA range map, supplanting dma_pfn_offset")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Jim Quinlan <jim2101024@gmail.com>
> ---
>  drivers/of/unittest.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 

Applied, thanks!

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

end of thread, other threads:[~2021-12-15 19:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-10 18:46 [PATCH v2 0/1] of: unittest: fix warning on PowerPC frame size warning Jim Quinlan
2021-12-10 18:46 ` [PATCH v2 1/1] " Jim Quinlan
2021-12-12 22:47   ` Frank Rowand
2021-12-13  7:24   ` Christoph Hellwig
2021-12-13 18:12   ` Florian Fainelli
2021-12-15 19:54   ` Rob Herring

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).