Skip to content

Commit ee1c71a

Browse files
Helen Koikemchehab
authored andcommitted
media: vimc: fix component match compare
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 <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Tested-by: Boris Brezillon <[email protected]> Signed-off-by: Hans Verkuil <[email protected]> Signed-off-by: Mauro Carvalho Chehab <[email protected]>
1 parent 3e0f724 commit ee1c71a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

drivers/media/platform/vimc/vimc-core.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,7 @@ static void vimc_comp_unbind(struct device *master)
244244

245245
static int vimc_comp_compare(struct device *comp, void *data)
246246
{
247-
const struct platform_device *pdev = to_platform_device(comp);
248-
const char *name = data;
249-
250-
return !strcmp(pdev->dev.platform_data, name);
247+
return comp == data;
251248
}
252249

253250
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)
277274
}
278275

279276
component_match_add(&vimc->pdev.dev, &match, vimc_comp_compare,
280-
(void *)vimc->pipe_cfg->ents[i].name);
277+
&vimc->subdevs[i]->dev);
281278
}
282279

283280
return match;

0 commit comments

Comments
 (0)