linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] intel-hid: allocate correct amount of memory for private struct
@ 2016-02-21 14:22 Wolfram Sang
  2016-02-22 22:27 ` Darren Hart
  0 siblings, 1 reply; 2+ messages in thread
From: Wolfram Sang @ 2016-02-21 14:22 UTC (permalink / raw)
  To: platform-driver-x86; +Cc: Wolfram Sang, Alex Hung, Darren Hart, linux-kernel

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

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

* Re: [PATCH] intel-hid: allocate correct amount of memory for private struct
  2016-02-21 14:22 [PATCH] intel-hid: allocate correct amount of memory for private struct Wolfram Sang
@ 2016-02-22 22:27 ` Darren Hart
  0 siblings, 0 replies; 2+ messages in thread
From: Darren Hart @ 2016-02-22 22:27 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: platform-driver-x86, Alex Hung, linux-kernel

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

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

end of thread, other threads:[~2016-02-22 22:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-21 14:22 [PATCH] intel-hid: allocate correct amount of memory for private struct Wolfram Sang
2016-02-22 22:27 ` Darren Hart

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