linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: vimc: fix component match compare
@ 2019-05-17 17:20 Helen Koike
  2019-05-21 12:53 ` Boris Brezillon
  2019-05-21 12:55 ` Boris Brezillon
  0 siblings, 2 replies; 5+ messages in thread
From: Helen Koike @ 2019-05-17 17:20 UTC (permalink / raw)
  To: linux-media
  Cc: hverkuil-cisco, kernel, ezequiel.garcia, andrealmeid,
	Helen Koike, Mauro Carvalho Chehab, linux-kernel

If the system has other devices being registered in the component
framework, the compare function will be called with a device that
doesn't belong to vimc.
This device is not necessarily a platform_device, nor have a
platform_data (which causes a NULL pointer dereference error) and if it
does have a pdata, it is not necessarily type of struct vimc_platform_data.
So casting to any of these types is wrong.

Instead of expecting a given pdev with a given pdata, just expect for
the device it self. vimc-core is the one who creates them, we know in
advance exactly which object to expect in the match.

Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules")
Signed-off-by: Helen Koike <helen.koike@collabora.com>

---

 drivers/media/platform/vimc/vimc-core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
index 3aa62d7e3d0e..23992affd01f 100644
--- a/drivers/media/platform/vimc/vimc-core.c
+++ b/drivers/media/platform/vimc/vimc-core.c
@@ -244,10 +244,7 @@ static void vimc_comp_unbind(struct device *master)
 
 static int vimc_comp_compare(struct device *comp, void *data)
 {
-	const struct platform_device *pdev = to_platform_device(comp);
-	const char *name = data;
-
-	return !strcmp(pdev->dev.platform_data, name);
+	return comp == data;
 }
 
 static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
@@ -277,7 +274,7 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
 		}
 
 		component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,
-				    (void *)vimc->pipe_cfg->ents[i].name);
+				    &vimc->subdevs[i]->dev);
 	}
 
 	return match;
-- 
2.20.1


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

* Re: [PATCH] media: vimc: fix component match compare
  2019-05-17 17:20 [PATCH] media: vimc: fix component match compare Helen Koike
@ 2019-05-21 12:53 ` Boris Brezillon
  2019-05-21 12:55 ` Boris Brezillon
  1 sibling, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2019-05-21 12:53 UTC (permalink / raw)
  To: Helen Koike
  Cc: linux-media, hverkuil-cisco, kernel, ezequiel.garcia,
	andrealmeid, Mauro Carvalho Chehab, linux-kernel

On Fri, 17 May 2019 14:20:11 -0300
Helen Koike <helen.koike@collabora.com> wrote:

> If the system has other devices being registered in the component
> framework, the compare function will be called with a device that
> doesn't belong to vimc.
> This device is not necessarily a platform_device, nor have a
> platform_data (which causes a NULL pointer dereference error) and if it
> does have a pdata, it is not necessarily type of struct vimc_platform_data.
> So casting to any of these types is wrong.
> 
> Instead of expecting a given pdev with a given pdata, just expect for
> the device it self. vimc-core is the one who creates them, we know in
> advance exactly which object to expect in the match.
> 
> Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules")
> Signed-off-by: Helen Koike <helen.koike@collabora.com>

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Tested-by: Boris Brezillon <boris.brezillon@collabora.com>

> 
> ---
> 
>  drivers/media/platform/vimc/vimc-core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
> index 3aa62d7e3d0e..23992affd01f 100644
> --- a/drivers/media/platform/vimc/vimc-core.c
> +++ b/drivers/media/platform/vimc/vimc-core.c
> @@ -244,10 +244,7 @@ static void vimc_comp_unbind(struct device *master)
>  
>  static int vimc_comp_compare(struct device *comp, void *data)
>  {
> -	const struct platform_device *pdev = to_platform_device(comp);
> -	const char *name = data;
> -
> -	return !strcmp(pdev->dev.platform_data, name);
> +	return comp == data;
>  }
>  
>  static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
> @@ -277,7 +274,7 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
>  		}
>  
>  		component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,
> -				    (void *)vimc->pipe_cfg->ents[i].name);
> +				    &vimc->subdevs[i]->dev);
>  	}
>  
>  	return match;


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

* Re: [PATCH] media: vimc: fix component match compare
  2019-05-17 17:20 [PATCH] media: vimc: fix component match compare Helen Koike
  2019-05-21 12:53 ` Boris Brezillon
@ 2019-05-21 12:55 ` Boris Brezillon
  2019-05-21 18:39   ` Ezequiel Garcia
  1 sibling, 1 reply; 5+ messages in thread
From: Boris Brezillon @ 2019-05-21 12:55 UTC (permalink / raw)
  To: Helen Koike
  Cc: linux-media, hverkuil-cisco, kernel, ezequiel.garcia,
	andrealmeid, Mauro Carvalho Chehab, linux-kernel

On Fri, 17 May 2019 14:20:11 -0300
Helen Koike <helen.koike@collabora.com> wrote:

> If the system has other devices being registered in the component
> framework, the compare function will be called with a device that
> doesn't belong to vimc.
> This device is not necessarily a platform_device, nor have a
> platform_data (which causes a NULL pointer dereference error) and if it
> does have a pdata, it is not necessarily type of struct vimc_platform_data.
> So casting to any of these types is wrong.
> 
> Instead of expecting a given pdev with a given pdata, just expect for
> the device it self. vimc-core is the one who creates them, we know in
> advance exactly which object to expect in the match.
> 
> Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules")

Oh, and you forgot to add

Cc: <stable@vger.kernel.org>

> Signed-off-by: Helen Koike <helen.koike@collabora.com>
> 
> ---
> 
>  drivers/media/platform/vimc/vimc-core.c | 7 ++-----
>  1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/media/platform/vimc/vimc-core.c b/drivers/media/platform/vimc/vimc-core.c
> index 3aa62d7e3d0e..23992affd01f 100644
> --- a/drivers/media/platform/vimc/vimc-core.c
> +++ b/drivers/media/platform/vimc/vimc-core.c
> @@ -244,10 +244,7 @@ static void vimc_comp_unbind(struct device *master)
>  
>  static int vimc_comp_compare(struct device *comp, void *data)
>  {
> -	const struct platform_device *pdev = to_platform_device(comp);
> -	const char *name = data;
> -
> -	return !strcmp(pdev->dev.platform_data, name);
> +	return comp == data;
>  }
>  
>  static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
> @@ -277,7 +274,7 @@ static struct component_match *vimc_add_subdevs(struct vimc_device *vimc)
>  		}
>  
>  		component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,
> -				    (void *)vimc->pipe_cfg->ents[i].name);
> +				    &vimc->subdevs[i]->dev);
>  	}
>  
>  	return match;


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

* Re: [PATCH] media: vimc: fix component match compare
  2019-05-21 12:55 ` Boris Brezillon
@ 2019-05-21 18:39   ` Ezequiel Garcia
  2019-05-21 18:53     ` Boris Brezillon
  0 siblings, 1 reply; 5+ messages in thread
From: Ezequiel Garcia @ 2019-05-21 18:39 UTC (permalink / raw)
  To: Boris Brezillon, Helen Koike
  Cc: linux-media, hverkuil-cisco, kernel, ezequiel.garcia,
	andrealmeid, Mauro Carvalho Chehab, linux-kernel

On Tue, 2019-05-21 at 14:55 +0200, Boris Brezillon wrote:
> On Fri, 17 May 2019 14:20:11 -0300
> Helen Koike <helen.koike@collabora.com> wrote:
> 
> > If the system has other devices being registered in the component
> > framework, the compare function will be called with a device that
> > doesn't belong to vimc.
> > This device is not necessarily a platform_device, nor have a
> > platform_data (which causes a NULL pointer dereference error) and if it
> > does have a pdata, it is not necessarily type of struct vimc_platform_data.
> > So casting to any of these types is wrong.
> > 
> > Instead of expecting a given pdev with a given pdata, just expect for
> > the device it self. vimc-core is the one who creates them, we know in
> > advance exactly which object to expect in the match.
> > 
> > Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules")
> 
> Oh, and you forgot to add
> 
> Cc: <stable@vger.kernel.org>
> 

Although it's not really documented (not in process/stable-rules
at least) that a "Fixes" tag alone would be automatically picked by
the stable team, it has been the case for me since always,
as I've never Cced stable explicitly.


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

* Re: [PATCH] media: vimc: fix component match compare
  2019-05-21 18:39   ` Ezequiel Garcia
@ 2019-05-21 18:53     ` Boris Brezillon
  0 siblings, 0 replies; 5+ messages in thread
From: Boris Brezillon @ 2019-05-21 18:53 UTC (permalink / raw)
  To: Ezequiel Garcia
  Cc: Helen Koike, linux-media, hverkuil-cisco, kernel,
	ezequiel.garcia, andrealmeid, Mauro Carvalho Chehab,
	linux-kernel

On Tue, 21 May 2019 15:39:00 -0300
Ezequiel Garcia <ezequiel@collabora.com> wrote:

> On Tue, 2019-05-21 at 14:55 +0200, Boris Brezillon wrote:
> > On Fri, 17 May 2019 14:20:11 -0300
> > Helen Koike <helen.koike@collabora.com> wrote:
> >   
> > > If the system has other devices being registered in the component
> > > framework, the compare function will be called with a device that
> > > doesn't belong to vimc.
> > > This device is not necessarily a platform_device, nor have a
> > > platform_data (which causes a NULL pointer dereference error) and if it
> > > does have a pdata, it is not necessarily type of struct vimc_platform_data.
> > > So casting to any of these types is wrong.
> > > 
> > > Instead of expecting a given pdev with a given pdata, just expect for
> > > the device it self. vimc-core is the one who creates them, we know in
> > > advance exactly which object to expect in the match.
> > > 
> > > Fixes: 4a29b7090749 ("[media] vimc: Subdevices as modules")  
> > 
> > Oh, and you forgot to add
> > 
> > Cc: <stable@vger.kernel.org>
> >   
> 
> Although it's not really documented (not in process/stable-rules
> at least) that a "Fixes" tag alone would be automatically picked by
> the stable team, it has been the case for me since always,
> as I've never Cced stable explicitly.
> 

It's probably the case thanks to Sascha's auto-select tool, but I do
think it's better to be explicit about what you want: there are some
cases where a patch fixes a bug, but the user doesn't want this patch
to be backported because it's not been tested or older kernels, is too
complex to be backported as is or is not important enough (typos).

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

end of thread, other threads:[~2019-05-21 18:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 17:20 [PATCH] media: vimc: fix component match compare Helen Koike
2019-05-21 12:53 ` Boris Brezillon
2019-05-21 12:55 ` Boris Brezillon
2019-05-21 18:39   ` Ezequiel Garcia
2019-05-21 18:53     ` Boris Brezillon

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