linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtd: zero out mtd_partion struct before using it
@ 2015-11-12  0:47 Brian Norris
  2015-11-12  8:52 ` Boris Brezillon
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Norris @ 2015-11-12  0:47 UTC (permalink / raw)
  To: linux-mtd; +Cc: Boris Brezillon, Brian Norris

It's easier to guarantee we've cleared out all unused fields with
memset() than by manually initializing each field.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
I hit this while testing out the added 'of_node' field:

  http://patchwork.ozlabs.org/patch/538838/

 drivers/mtd/mtdpart.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
index c2b6e967a160..3ace53342fd2 100644
--- a/drivers/mtd/mtdpart.c
+++ b/drivers/mtd/mtdpart.c
@@ -597,11 +597,10 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
 	if (length <= 0)
 		return -EINVAL;
 
+	memset(&part, 0, sizeof(part));
 	part.name = name;
 	part.size = length;
 	part.offset = offset;
-	part.mask_flags = 0;
-	part.ecclayout = NULL;
 
 	new = allocate_partition(master, &part, -1, offset);
 	if (IS_ERR(new))
-- 
2.6.0.rc2.230.g3dd15c0

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

* Re: [PATCH] mtd: zero out mtd_partion struct before using it
  2015-11-12  0:47 [PATCH] mtd: zero out mtd_partion struct before using it Brian Norris
@ 2015-11-12  8:52 ` Boris Brezillon
  2015-11-12 18:13   ` Brian Norris
  0 siblings, 1 reply; 3+ messages in thread
From: Boris Brezillon @ 2015-11-12  8:52 UTC (permalink / raw)
  To: Brian Norris; +Cc: linux-mtd

On Wed, 11 Nov 2015 16:47:52 -0800
Brian Norris <computersforpeace@gmail.com> wrote:

> It's easier to guarantee we've cleared out all unused fields with
> memset() than by manually initializing each field.
> 
> Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

> ---
> I hit this while testing out the added 'of_node' field:
> 
>   http://patchwork.ozlabs.org/patch/538838/
> 
>  drivers/mtd/mtdpart.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c
> index c2b6e967a160..3ace53342fd2 100644
> --- a/drivers/mtd/mtdpart.c
> +++ b/drivers/mtd/mtdpart.c
> @@ -597,11 +597,10 @@ int mtd_add_partition(struct mtd_info *master, const char *name,
>  	if (length <= 0)
>  		return -EINVAL;
>  
> +	memset(&part, 0, sizeof(part));
>  	part.name = name;
>  	part.size = length;
>  	part.offset = offset;
> -	part.mask_flags = 0;
> -	part.ecclayout = NULL;
>  
>  	new = allocate_partition(master, &part, -1, offset);
>  	if (IS_ERR(new))



-- 
Boris Brezillon, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com

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

* Re: [PATCH] mtd: zero out mtd_partion struct before using it
  2015-11-12  8:52 ` Boris Brezillon
@ 2015-11-12 18:13   ` Brian Norris
  0 siblings, 0 replies; 3+ messages in thread
From: Brian Norris @ 2015-11-12 18:13 UTC (permalink / raw)
  To: Boris Brezillon; +Cc: linux-mtd

On Thu, Nov 12, 2015 at 09:52:19AM +0100, Boris Brezillon wrote:
> On Wed, 11 Nov 2015 16:47:52 -0800
> Brian Norris <computersforpeace@gmail.com> wrote:
> 
> > It's easier to guarantee we've cleared out all unused fields with
> > memset() than by manually initializing each field.
> > 
> > Signed-off-by: Brian Norris <computersforpeace@gmail.com>
> 
> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>

Pushed to l2-mtd.git/next

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

end of thread, other threads:[~2015-11-12 18:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-12  0:47 [PATCH] mtd: zero out mtd_partion struct before using it Brian Norris
2015-11-12  8:52 ` Boris Brezillon
2015-11-12 18:13   ` Brian Norris

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