Message ID | 20210118081446.46555-1-tomi.valkeinen@ideasonboard.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | media: i2c: max9286: fix access to unallocated memory | expand |
Hi Tomi, Thank you for the patch. On Mon, Jan 18, 2021 at 10:14:46AM +0200, Tomi Valkeinen wrote: > The asd allocated with v4l2_async_notifier_add_fwnode_subdev() must be > of size max9286_asd, otherwise access to max9286_asd->source will go to > unallocated memory. > > Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically") > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > Cc: stable@vger.kernel.org # v5.10+ Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> > --- > drivers/media/i2c/max9286.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c > index c82c1493e099..b1e2476d3c9e 100644 > --- a/drivers/media/i2c/max9286.c > +++ b/drivers/media/i2c/max9286.c > @@ -580,7 +580,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv) > > asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier, > source->fwnode, > - sizeof(*asd)); > + sizeof(struct max9286_asd)); > if (IS_ERR(asd)) { > dev_err(dev, "Failed to add subdev for source %u: %ld", > i, PTR_ERR(asd));
Hi Tomi, On 18/01/2021 08:14, Tomi Valkeinen wrote: > The asd allocated with v4l2_async_notifier_add_fwnode_subdev() must be > of size max9286_asd, otherwise access to max9286_asd->source will go to > unallocated memory. > > Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically") > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > Cc: stable@vger.kernel.org # v5.10+ Thanks this looks like a good spot. Reviewed-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> And also, now verified: Tested-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com> > --- > drivers/media/i2c/max9286.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c > index c82c1493e099..b1e2476d3c9e 100644 > --- a/drivers/media/i2c/max9286.c > +++ b/drivers/media/i2c/max9286.c > @@ -580,7 +580,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv) > > asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier, > source->fwnode, > - sizeof(*asd)); > + sizeof(struct max9286_asd)); > if (IS_ERR(asd)) { > dev_err(dev, "Failed to add subdev for source %u: %ld", > i, PTR_ERR(asd)); >
diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c index c82c1493e099..b1e2476d3c9e 100644 --- a/drivers/media/i2c/max9286.c +++ b/drivers/media/i2c/max9286.c @@ -580,7 +580,7 @@ static int max9286_v4l2_notifier_register(struct max9286_priv *priv) asd = v4l2_async_notifier_add_fwnode_subdev(&priv->notifier, source->fwnode, - sizeof(*asd)); + sizeof(struct max9286_asd)); if (IS_ERR(asd)) { dev_err(dev, "Failed to add subdev for source %u: %ld", i, PTR_ERR(asd));
The asd allocated with v4l2_async_notifier_add_fwnode_subdev() must be of size max9286_asd, otherwise access to max9286_asd->source will go to unallocated memory. Fixes: 86d37bf31af6 ("media: i2c: max9286: Allocate v4l2_async_subdev dynamically") Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> Cc: stable@vger.kernel.org # v5.10+ --- drivers/media/i2c/max9286.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)