diff mbox series

v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()

Message ID 20240930074602.500968-1-prabhakar.mahadev-lad.rj@bp.renesas.com (mailing list archive)
State New
Headers show
Series v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc() | expand

Commit Message

Prabhakar Sept. 30, 2024, 7:46 a.m. UTC
From: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>

The `get_frame_desc()` operation should always be called on a source pad,
which is indicated by the `MEDIA_PAD_FL_SOURCE` flag. This patch adds a
check in `call_get_frame_desc()` to ensure that the `MEDIA_PAD_FL_SOURCE`
flag is set for the pad before invoking `get_frame_desc()`. If the pad is
not a source pad, the function will return an `-EOPNOTSUPP` error,
signaling that the operation is not supported on non-source pads.

Suggested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/media/v4l2-core/v4l2-subdev.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

kernel test robot Oct. 5, 2024, 11:59 p.m. UTC | #1
Hi Prabhakar,

kernel test robot noticed the following build errors:

[auto build test ERROR on media-tree/master]
[also build test ERROR on sailus-media-tree/master linus/master v6.12-rc1 next-20241004]
[cannot apply to sailus-media-tree/streams]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Prabhakar/v4l2-subdev-Return-EOPNOTSUPP-for-unsupported-pad-type-in-call_get_frame_desc/20240930-154811
base:   git://linuxtv.org/media_tree.git master
patch link:    https://lore.kernel.org/r/20240930074602.500968-1-prabhakar.mahadev-lad.rj%40bp.renesas.com
patch subject: [PATCH] v4l2-subdev: Return -EOPNOTSUPP for unsupported pad type in call_get_frame_desc()
config: x86_64-randconfig-003-20241002 (https://download.01.org/0day-ci/archive/20241006/202410060640.ykY9JvqZ-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241006/202410060640.ykY9JvqZ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202410060640.ykY9JvqZ-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/media/v4l2-core/v4l2-subdev.c:337:12: error: no member named 'entity' in 'struct v4l2_subdev'
     337 |         if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
         |               ~~  ^
   1 error generated.


vim +337 drivers/media/v4l2-core/v4l2-subdev.c

   330	
   331	static int call_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
   332				       struct v4l2_mbus_frame_desc *fd)
   333	{
   334		unsigned int i;
   335		int ret;
   336	
 > 337		if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
   338			return -EOPNOTSUPP;
   339	
   340		memset(fd, 0, sizeof(*fd));
   341	
   342		ret = sd->ops->pad->get_frame_desc(sd, pad, fd);
   343		if (ret)
   344			return ret;
   345	
   346		dev_dbg(sd->dev, "Frame descriptor on pad %u, type %s\n", pad,
   347			fd->type == V4L2_MBUS_FRAME_DESC_TYPE_PARALLEL ? "parallel" :
   348			fd->type == V4L2_MBUS_FRAME_DESC_TYPE_CSI2 ? "CSI-2" :
   349			"unknown");
   350	
   351		for (i = 0; i < fd->num_entries; i++) {
   352			struct v4l2_mbus_frame_desc_entry *entry = &fd->entry[i];
   353			char buf[20] = "";
   354	
   355			if (fd->type == V4L2_MBUS_FRAME_DESC_TYPE_CSI2)
   356				WARN_ON(snprintf(buf, sizeof(buf),
   357						 ", vc %u, dt 0x%02x",
   358						 entry->bus.csi2.vc,
   359						 entry->bus.csi2.dt) >= sizeof(buf));
   360	
   361			dev_dbg(sd->dev,
   362				"\tstream %u, code 0x%04x, length %u, flags 0x%04x%s\n",
   363				entry->stream, entry->pixelcode, entry->length,
   364				entry->flags, buf);
   365		}
   366	
   367		return 0;
   368	}
   369
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index de9ac67574bb..ea8e8976272d 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -325,6 +325,9 @@  static int call_get_frame_desc(struct v4l2_subdev *sd, unsigned int pad,
 	unsigned int i;
 	int ret;
 
+	if (!(sd->entity.pads[pad].flags & MEDIA_PAD_FL_SOURCE))
+		return -EOPNOTSUPP;
+
 	memset(fd, 0, sizeof(*fd));
 
 	ret = sd->ops->pad->get_frame_desc(sd, pad, fd);