Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1338874 > unrolled thread

[PATCH] intel-hid: allocate correct amount of memory for private struct

Started byWolfram Sang <wsa@the-dreams.de>
First post2016-02-21 18:40 +0100
Last post2016-02-22 23:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] intel-hid: allocate correct amount of memory for private struct Wolfram Sang <wsa@the-dreams.de> - 2016-02-21 18:40 +0100
    Re: [PATCH] intel-hid: allocate correct amount of memory for private  struct Darren Hart <dvhart@infradead.org> - 2016-02-22 23:30 +0100

#1338874 — [PATCH] intel-hid: allocate correct amount of memory for private struct

FromWolfram Sang <wsa@the-dreams.de>
Date2016-02-21 18:40 +0100
Subject[PATCH] intel-hid: allocate correct amount of memory for private struct
Message-ID<r4G9e-XY-49@gated-at.bofh.it>
We want the size of the struct, not of a pointer to it. To be future
proof, just dereference the pointer to get the desired type.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---

Compile tested only. Found by static code analysis.

 drivers/platform/x86/intel-hid.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
index e20f23e04c24ce..f93abc8c1424ad 100644
--- a/drivers/platform/x86/intel-hid.c
+++ b/drivers/platform/x86/intel-hid.c
@@ -180,8 +180,7 @@ static int intel_hid_probe(struct platform_device *device)
 		return -ENODEV;
 	}
 
-	priv = devm_kzalloc(&device->dev,
-			    sizeof(struct intel_hid_priv *), GFP_KERNEL);
+	priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 	dev_set_drvdata(&device->dev, priv);
-- 
2.7.0

[toc] | [next] | [standalone]


#1339988 — Re: [PATCH] intel-hid: allocate correct amount of memory for private struct

FromDarren Hart <dvhart@infradead.org>
Date2016-02-22 23:30 +0100
SubjectRe: [PATCH] intel-hid: allocate correct amount of memory for private struct
Message-ID<r579o-4ce-23@gated-at.bofh.it>
In reply to#1338874
On Sun, Feb 21, 2016 at 03:22:27PM +0100, Wolfram Sang wrote:
> We want the size of the struct, not of a pointer to it. To be future
> proof, just dereference the pointer to get the desired type.
> 
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

Queued to testing. Thank you Wolfram.

> ---
> 
> Compile tested only. Found by static code analysis.
> 
>  drivers/platform/x86/intel-hid.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c
> index e20f23e04c24ce..f93abc8c1424ad 100644
> --- a/drivers/platform/x86/intel-hid.c
> +++ b/drivers/platform/x86/intel-hid.c
> @@ -180,8 +180,7 @@ static int intel_hid_probe(struct platform_device *device)
>  		return -ENODEV;
>  	}
>  
> -	priv = devm_kzalloc(&device->dev,
> -			    sizeof(struct intel_hid_priv *), GFP_KERNEL);
> +	priv = devm_kzalloc(&device->dev, sizeof(*priv), GFP_KERNEL);
>  	if (!priv)
>  		return -ENOMEM;
>  	dev_set_drvdata(&device->dev, priv);
> -- 
> 2.7.0
> 
> 

-- 
Darren Hart
Intel Open Source Technology Center

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web