* [PATCH] media: i2c: max9286: Fix async subdev size
@ 2020-09-14 15:57 Jacopo Mondi
2020-09-14 23:30 ` Laurent Pinchart
0 siblings, 1 reply; 4+ messages in thread
From: Jacopo Mondi @ 2020-09-14 15:57 UTC (permalink / raw)
To: Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Mauro Carvalho Chehab
Cc: Jacopo Mondi, linux-renesas-soc, linux-media
Since commit:
86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
the async subdevice registered to the max9286 notifier is dynamically
allocated by the v4l2 framework by using
the v4l2_async_notifier_add_fwnode_subdev function. In order to allocate
enough space for max9286_asd structure that encloses the async subdevice
paired with a pointer to the corresponding source, pass to the framework
the size of the whole structure in place of the one of the enclosed async
subdev.
Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
---
drivers/media/i2c/max9286.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index c82c1493e099..746c411b79a0 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -579,8 +579,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv)
struct v4l2_async_subdev *asd;
asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
- source->fwnode,
- sizeof(*asd));
+ source->fwnode, sizeof(struct max9286_asd));
if (IS_ERR(asd)) {
dev_err(dev, "Failed to add subdev for source %u: %ld",
i, PTR_ERR(asd));
--
2.28.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] media: i2c: max9286: Fix async subdev size
2020-09-14 15:57 [PATCH] media: i2c: max9286: Fix async subdev size Jacopo Mondi
@ 2020-09-14 23:30 ` Laurent Pinchart
2020-09-15 12:28 ` Jacopo Mondi
2020-09-16 10:30 ` Kieran Bingham
0 siblings, 2 replies; 4+ messages in thread
From: Laurent Pinchart @ 2020-09-14 23:30 UTC (permalink / raw)
To: Jacopo Mondi
Cc: Kieran Bingham, Laurent Pinchart, Niklas Söderlund,
Mauro Carvalho Chehab, linux-renesas-soc, linux-media
Hi Jacopo,
Thank you for the patch.
On Mon, Sep 14, 2020 at 05:57:49PM +0200, Jacopo Mondi wrote:
> Since commit:
> 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
> the async subdevice registered to the max9286 notifier is dynamically
> allocated by the v4l2 framework by using
> the v4l2_async_notifier_add_fwnode_subdev function. In order to allocate
> enough space for max9286_asd structure that encloses the async subdevice
> paired with a pointer to the corresponding source, pass to the framework
> the size of the whole structure in place of the one of the enclosed async
> subdev.
>
> Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> ---
> drivers/media/i2c/max9286.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> index c82c1493e099..746c411b79a0 100644
> --- a/drivers/media/i2c/max9286.c
> +++ b/drivers/media/i2c/max9286.c
> @@ -579,8 +579,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv)
> struct v4l2_async_subdev *asd;
>
> asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
> - source->fwnode,
> - sizeof(*asd));
> + source->fwnode, sizeof(struct max9286_asd));
I'd write
struct v4l2_async_subdev *asd;
struct max9286_asd *masd;
asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
source->fwnode,
sizeof(*masd));
if (IS_ERR(asd)) {
dev_err(dev, "Failed to add subdev for source %u: %ld",
i, PTR_ERR(asd));
v4l2_async_notifier_cleanup(&priv->notifier);
return PTR_ERR(asd);
}
masd = to_max9286_asd(asd);
masd->source = source;
just to be able to avoid the ugly indentiation, but that's really
nitpicking :-) With or without that, sorry for breaking the driver in
the first place, and
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
> if (IS_ERR(asd)) {
> dev_err(dev, "Failed to add subdev for source %u: %ld",
> i, PTR_ERR(asd));
--
Regards,
Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: i2c: max9286: Fix async subdev size
2020-09-14 23:30 ` Laurent Pinchart
@ 2020-09-15 12:28 ` Jacopo Mondi
2020-09-16 10:30 ` Kieran Bingham
1 sibling, 0 replies; 4+ messages in thread
From: Jacopo Mondi @ 2020-09-15 12:28 UTC (permalink / raw)
To: Laurent Pinchart
Cc: Jacopo Mondi, Kieran Bingham, Laurent Pinchart,
Niklas Söderlund, Mauro Carvalho Chehab, linux-renesas-soc,
linux-media
Hi Laurent,
On Tue, Sep 15, 2020 at 02:30:08AM +0300, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Mon, Sep 14, 2020 at 05:57:49PM +0200, Jacopo Mondi wrote:
> > Since commit:
> > 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
> > the async subdevice registered to the max9286 notifier is dynamically
> > allocated by the v4l2 framework by using
> > the v4l2_async_notifier_add_fwnode_subdev function. In order to allocate
> > enough space for max9286_asd structure that encloses the async subdevice
> > paired with a pointer to the corresponding source, pass to the framework
> > the size of the whole structure in place of the one of the enclosed async
> > subdev.
> >
> > Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
> > Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
> > ---
> > drivers/media/i2c/max9286.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
> > index c82c1493e099..746c411b79a0 100644
> > --- a/drivers/media/i2c/max9286.c
> > +++ b/drivers/media/i2c/max9286.c
> > @@ -579,8 +579,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv)
> > struct v4l2_async_subdev *asd;
> >
> > asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
> > - source->fwnode,
> > - sizeof(*asd));
> > + source->fwnode, sizeof(struct max9286_asd));
>
> I'd write
>
> struct v4l2_async_subdev *asd;
> struct max9286_asd *masd;
>
> asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
> source->fwnode,
> sizeof(*masd));
> if (IS_ERR(asd)) {
> dev_err(dev, "Failed to add subdev for source %u: %ld",
> i, PTR_ERR(asd));
> v4l2_async_notifier_cleanup(&priv->notifier);
> return PTR_ERR(asd);
> }
>
> masd = to_max9286_asd(asd);
> masd->source = source;
I considered the same, but then decided that indent was not that bad,
but I can indeed change it, I like this version better after all.
>
> just to be able to avoid the ugly indentiation, but that's really
> nitpicking :-) With or without that, sorry for breaking the driver in
> the first place, and
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Thanks
j
>
> > if (IS_ERR(asd)) {
> > dev_err(dev, "Failed to add subdev for source %u: %ld",
> > i, PTR_ERR(asd));
>
> --
> Regards,
>
> Laurent Pinchart
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] media: i2c: max9286: Fix async subdev size
2020-09-14 23:30 ` Laurent Pinchart
2020-09-15 12:28 ` Jacopo Mondi
@ 2020-09-16 10:30 ` Kieran Bingham
1 sibling, 0 replies; 4+ messages in thread
From: Kieran Bingham @ 2020-09-16 10:30 UTC (permalink / raw)
To: Laurent Pinchart, Jacopo Mondi
Cc: Laurent Pinchart, Niklas Söderlund, Mauro Carvalho Chehab,
linux-renesas-soc, linux-media
On 15/09/2020 00:30, Laurent Pinchart wrote:
> Hi Jacopo,
>
> Thank you for the patch.
>
> On Mon, Sep 14, 2020 at 05:57:49PM +0200, Jacopo Mondi wrote:
>> Since commit:
>> 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
>> the async subdevice registered to the max9286 notifier is dynamically
>> allocated by the v4l2 framework by using
>> the v4l2_async_notifier_add_fwnode_subdev function. In order to allocate
>> enough space for max9286_asd structure that encloses the async subdevice
>> paired with a pointer to the corresponding source, pass to the framework
>> the size of the whole structure in place of the one of the enclosed async
>> subdev.
>>
>> Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically")
>> Signed-off-by: Jacopo Mondi <jacopo+renesas@jmondi.org>
>> ---
>> drivers/media/i2c/max9286.c | 3 +--
>> 1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
>> index c82c1493e099..746c411b79a0 100644
>> --- a/drivers/media/i2c/max9286.c
>> +++ b/drivers/media/i2c/max9286.c
>> @@ -579,8 +579,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv)
>> struct v4l2_async_subdev *asd;
>>
>> asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
>> - source->fwnode,
>> - sizeof(*asd));
>> + source->fwnode, sizeof(struct max9286_asd));
>
> I'd write
>
> struct v4l2_async_subdev *asd;
> struct max9286_asd *masd;
>
> asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier,
> source->fwnode,
> sizeof(*masd));
Ha, at first glance that looks like you're dereferencing an
uninitialised pointer though.
But it's only the sizeof - so the actual pointer doesn't matter at that
point ;-)
--
Kieran
> if (IS_ERR(asd)) {
> dev_err(dev, "Failed to add subdev for source %u: %ld",
> i, PTR_ERR(asd));
> v4l2_async_notifier_cleanup(&priv->notifier);
> return PTR_ERR(asd);
> }
>
> masd = to_max9286_asd(asd);
> masd->source = source;
>
> just to be able to avoid the ugly indentiation, but that's really
> nitpicking :-) With or without that, sorry for breaking the driver in
> the first place, and
>
> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
>
>> if (IS_ERR(asd)) {
>> dev_err(dev, "Failed to add subdev for source %u: %ld",
>> i, PTR_ERR(asd));
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-09-16 10:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 15:57 [PATCH] media: i2c: max9286: Fix async subdev size Jacopo Mondi
2020-09-14 23:30 ` Laurent Pinchart
2020-09-15 12:28 ` Jacopo Mondi
2020-09-16 10:30 ` Kieran Bingham
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.