Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aff093d4 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Mauro Carvalho Chehab
Browse files

[media] exynos-gsc: avoid build warning without CONFIG_OF



When building the exynos-gsc driver with CONFIG_OF disabled, we get
a warning about an out-of-bounds access:

drivers/media/platform/exynos-gsc/gsc-core.c: In function 'gsc_probe':
drivers/media/platform/exynos-gsc/gsc-core.c:1078:34: error: array subscript is above array bounds [-Werror=array-bounds]

This is harmless because the driver will never be used without CONFIG_OF,
but it's better to avoid the warning anyway. Checking the return value
of of_alias_get_id() for an error condition is probably a good idea
anyway, and it makes sure the compiler can verify that we don't get
into that situation.

Fixes: 26a7ed9c ("[media] exynos-gsc: remove an always false condition")

Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 0185f850
Loading
Loading
Loading
Loading
+6 −2
Original line number Original line Diff line number Diff line
@@ -1063,13 +1063,17 @@ static int gsc_probe(struct platform_device *pdev)
	struct resource *res;
	struct resource *res;
	struct gsc_driverdata *drv_data = gsc_get_drv_data(pdev);
	struct gsc_driverdata *drv_data = gsc_get_drv_data(pdev);
	struct device *dev = &pdev->dev;
	struct device *dev = &pdev->dev;
	int ret = 0;
	int ret;


	gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL);
	gsc = devm_kzalloc(dev, sizeof(struct gsc_dev), GFP_KERNEL);
	if (!gsc)
	if (!gsc)
		return -ENOMEM;
		return -ENOMEM;


	gsc->id = of_alias_get_id(pdev->dev.of_node, "gsc");
	ret = of_alias_get_id(pdev->dev.of_node, "gsc");
	if (ret < 0)
		return ret;

	gsc->id = ret;
	if (gsc->id >= drv_data->num_entities) {
	if (gsc->id >= drv_data->num_entities) {
		dev_err(dev, "Invalid platform device id: %d\n", gsc->id);
		dev_err(dev, "Invalid platform device id: %d\n", gsc->id);
		return -EINVAL;
		return -EINVAL;