Skip to content

Commit

Permalink
media: vimc: fix component match compare
Browse files Browse the repository at this point in the history
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: 4a29b70 ("[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>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
  • Loading branch information
helen-fornazier authored and mchehab committed May 28, 2019
1 parent 3e0f724 commit ee1c71a
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/media/platform/vimc/vimc-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit ee1c71a

Please sign in to comment.