omap3isp: Correctly put the last iterated endpoint fwnode always
Put the last endpoint fwnode if there are too many endpoints to handle.
Also tell the user about about the condition.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
diff --git a/drivers/media/platform/omap3isp/isp.c b/drivers/media/platform/omap3isp/isp.c
index c5f9927..776f708 100644
--- a/drivers/media/platform/omap3isp/isp.c
+++ b/drivers/media/platform/omap3isp/isp.c
@@ -2160,11 +2160,16 @@ static int isp_fwnodes_parse(struct device *dev,
if (!notifier->subdevs)
return -ENOMEM;
- while (notifier->num_subdevs < ISP_MAX_SUBDEVS &&
- (fwnode = fwnode_graph_get_next_endpoint(
- of_fwnode_handle(dev->of_node), fwnode))) {
+ while ((fwnode = fwnode_graph_get_next_endpoint(dev_fwnode(dev),
+ fwnode))) {
struct isp_async_subdev *isd;
+ if (notifier->num_subdevs >= ISP_MAX_SUBDEVS) {
+ dev_warn(dev, "too many endpoints, ignoring\n");
+ fwnode_handle_put(fwnode);
+ break;
+ }
+
isd = devm_kzalloc(dev, sizeof(*isd), GFP_KERNEL);
if (!isd)
goto error;