From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D633AC32771 for ; Mon, 26 Sep 2022 05:56:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbiIZF4g (ORCPT ); Mon, 26 Sep 2022 01:56:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40068 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231396AbiIZF4e (ORCPT ); Mon, 26 Sep 2022 01:56:34 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCAC24BD6 for ; Sun, 25 Sep 2022 22:56:34 -0700 (PDT) Received: from [192.168.1.15] (91-158-154-79.elisa-laajakaista.fi [91.158.154.79]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2242E2B3; Mon, 26 Sep 2022 07:56:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1664171791; bh=aJwZBmIGSSoXZjj42X9UVlvc8K2hagK/NdaCSWX/aVk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=O7RBtesEmMCmJtMoPx8CQb3oeZTf7/sp9ZTTjD87SfAkHuKNCQ4rQ/maiUn7mxwjE 8TVeSVnulXMUurAKANm6rcbqY7hv1q3ek04rvCyVFIldQR2vtqqJPpaEWaWXfALCf6 QYJKkLcPpBmUZ/+sQp/rUYwqEWgJbnRLvh8H9QWc= Message-ID: <2188d722-e241-f913-7dc0-0b8eee0ae86c@ideasonboard.com> Date: Mon, 26 Sep 2022 08:56:29 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v14 22/34] media: subdev: add v4l2_subdev_set_routing helper() Content-Language: en-US To: Sakari Ailus Cc: linux-media@vger.kernel.org, Jacopo Mondi , Laurent Pinchart , niklas.soderlund+renesas@ragnatech.se, Mauro Carvalho Chehab , Hans Verkuil , Kishon Vijay Abraham , satish.nagireddy@getcruise.com, Tomasz Figa References: <20220831141357.1396081-1-tomi.valkeinen@ideasonboard.com> <20220831141357.1396081-23-tomi.valkeinen@ideasonboard.com> From: Tomi Valkeinen In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On 25/09/2022 14:26, Sakari Ailus wrote: > Moi, > > On Wed, Aug 31, 2022 at 05:13:45PM +0300, Tomi Valkeinen wrote: >> Add a helper function to set the subdev routing. The helper can be used >> from subdev driver's set_routing op to store the routing table. >> >> Signed-off-by: Tomi Valkeinen >> Reviewed-by: Hans Verkuil >> --- >> drivers/media/v4l2-core/v4l2-subdev.c | 28 +++++++++++++++++++++++++++ >> include/media/v4l2-subdev.h | 16 +++++++++++++++ >> 2 files changed, 44 insertions(+) >> >> diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c >> index 1ce9a7dc0c6e..f3f872c72180 100644 >> --- a/drivers/media/v4l2-core/v4l2-subdev.c >> +++ b/drivers/media/v4l2-core/v4l2-subdev.c >> @@ -1180,6 +1180,34 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state, >> } >> EXPORT_SYMBOL_GPL(v4l2_subdev_get_fmt); >> >> +int v4l2_subdev_set_routing(struct v4l2_subdev *sd, >> + struct v4l2_subdev_state *state, >> + const struct v4l2_subdev_krouting *routing) >> +{ >> + struct v4l2_subdev_krouting *dst = &state->routing; >> + const struct v4l2_subdev_krouting *src = routing; >> + struct v4l2_subdev_krouting new_routing = { 0 }; >> + >> + lockdep_assert_held(state->lock); >> + >> + if (src->num_routes > 0) { >> + new_routing.routes = kmemdup(src->routes, >> + src->num_routes * sizeof(*src->routes), > > This can overflow. Right. In practice it won't happen as the num_routes has been limited to 256, but no harm to check for overflow here. Tomi