All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pwm: devm: alloc correct pointer size
@ 2013-06-03 20:27 Wolfram Sang
  2013-06-06 19:43 ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-06-03 20:27 UTC (permalink / raw)
  To: linux-kernel; +Cc: Wolfram Sang, Thierry Reding

The allocated object should be the size of what the pointer is pointing
to and not the size of the pointer itself.

Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
---
 drivers/pwm/core.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 32221cb..0cf0f65 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -694,7 +694,7 @@ struct pwm_device *devm_pwm_get(struct device *dev, const char *con_id)
 {
 	struct pwm_device **ptr, *pwm;
 
-	ptr = devres_alloc(devm_pwm_release, sizeof(**ptr), GFP_KERNEL);
+	ptr = devres_alloc(devm_pwm_release, sizeof(*ptr), GFP_KERNEL);
 	if (!ptr)
 		return ERR_PTR(-ENOMEM);
 
@@ -724,7 +724,7 @@ struct pwm_device *devm_of_pwm_get(struct device *dev, struct device_node *np,
 {
 	struct pwm_device **ptr, *pwm;
 
-	ptr = devres_alloc(devm_pwm_release, sizeof(**ptr), GFP_KERNEL);
+	ptr = devres_alloc(devm_pwm_release, sizeof(*ptr), GFP_KERNEL);
 	if (!ptr)
 		return ERR_PTR(-ENOMEM);
 
-- 
1.7.10.4


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

* Re: [PATCH] pwm: devm: alloc correct pointer size
  2013-06-03 20:27 [PATCH] pwm: devm: alloc correct pointer size Wolfram Sang
@ 2013-06-06 19:43 ` Andy Shevchenko
  2013-06-10  0:04   ` Wolfram Sang
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2013-06-06 19:43 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, Thierry Reding

On Mon, Jun 3, 2013 at 11:27 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> The allocated object should be the size of what the pointer is pointing
> to and not the size of the pointer itself.

All devm_* functions in this module use **ptr as a parameter (except
allocation).
May be we first should understand why it so?
If it wrong approach, than probably you have to change **ptr -> *ptr.
But without answer on first question I don't know if it proper solution or not.

--
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] pwm: devm: alloc correct pointer size
  2013-06-06 19:43 ` Andy Shevchenko
@ 2013-06-10  0:04   ` Wolfram Sang
  2013-06-10  6:41     ` Andy Shevchenko
  0 siblings, 1 reply; 5+ messages in thread
From: Wolfram Sang @ 2013-06-10  0:04 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-kernel, Thierry Reding

[-- Attachment #1: Type: text/plain, Size: 711 bytes --]

On Thu, Jun 06, 2013 at 10:43:41PM +0300, Andy Shevchenko wrote:
> On Mon, Jun 3, 2013 at 11:27 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> > The allocated object should be the size of what the pointer is pointing
> > to and not the size of the pointer itself.
> 
> All devm_* functions in this module use **ptr as a parameter (except
> allocation).
> May be we first should understand why it so?

Huh? **ptr is already created on the stack, but assigned the alloced
memory. Later, the mem it points to is set to 'pwm' which is then added
to devres. So, the alloced memory must be able to contain '*ptr' (or
*pwm which would be more readable IMO, but other subsystems also stick
to *ptr), no?


[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

* Re: [PATCH] pwm: devm: alloc correct pointer size
  2013-06-10  0:04   ` Wolfram Sang
@ 2013-06-10  6:41     ` Andy Shevchenko
  2013-06-10 10:51       ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Andy Shevchenko @ 2013-06-10  6:41 UTC (permalink / raw)
  To: Wolfram Sang; +Cc: linux-kernel, Thierry Reding

On Mon, Jun 10, 2013 at 3:04 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> On Thu, Jun 06, 2013 at 10:43:41PM +0300, Andy Shevchenko wrote:
>> On Mon, Jun 3, 2013 at 11:27 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
>> > The allocated object should be the size of what the pointer is pointing
>> > to and not the size of the pointer itself.
>>
>> All devm_* functions in this module use **ptr as a parameter (except
>> allocation).
>> May be we first should understand why it so?
>
> Huh? **ptr is already created on the stack, but assigned the alloced
> memory. Later, the mem it points to is set to 'pwm' which is then added
> to devres. So, the alloced memory must be able to contain '*ptr' (or
> *pwm which would be more readable IMO, but other subsystems also stick
> to *ptr), no?

Yes, you right.
Take my Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

--
With Best Regards,
Andy Shevchenko

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

* Re: [PATCH] pwm: devm: alloc correct pointer size
  2013-06-10  6:41     ` Andy Shevchenko
@ 2013-06-10 10:51       ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2013-06-10 10:51 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Wolfram Sang, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1020 bytes --]

On Mon, Jun 10, 2013 at 09:41:52AM +0300, Andy Shevchenko wrote:
> On Mon, Jun 10, 2013 at 3:04 AM, Wolfram Sang <wsa@the-dreams.de> wrote:
> > On Thu, Jun 06, 2013 at 10:43:41PM +0300, Andy Shevchenko wrote:
> >> On Mon, Jun 3, 2013 at 11:27 PM, Wolfram Sang <wsa@the-dreams.de> wrote:
> >> > The allocated object should be the size of what the pointer is pointing
> >> > to and not the size of the pointer itself.
> >>
> >> All devm_* functions in this module use **ptr as a parameter (except
> >> allocation).
> >> May be we first should understand why it so?
> >
> > Huh? **ptr is already created on the stack, but assigned the alloced
> > memory. Later, the mem it points to is set to 'pwm' which is then added
> > to devres. So, the alloced memory must be able to contain '*ptr' (or
> > *pwm which would be more readable IMO, but other subsystems also stick
> > to *ptr), no?
> 
> Yes, you right.
> Take my Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>

Applied, thanks.

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2013-06-10 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-03 20:27 [PATCH] pwm: devm: alloc correct pointer size Wolfram Sang
2013-06-06 19:43 ` Andy Shevchenko
2013-06-10  0:04   ` Wolfram Sang
2013-06-10  6:41     ` Andy Shevchenko
2013-06-10 10:51       ` Thierry Reding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.