Re: [PATCH 1/3] media: Zero-initialize all structures passed to subdev pad operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/15/23 09:50, Laurent Pinchart wrote:
Several drivers call subdev pad operations, passing structures that are
not fully zeroed. While the drivers initialize the fields they care
about explicitly, this results in reserved fields having uninitialized
values. Future kernel API changes that make use of those fields thus
risk breaking proper driver operation in ways that could be hard to
detect.

To avoid this, make the code more robust by zero-initializing all the
structures passed to subdev pad operation. Maintain a consistent coding
style by preferring designated initializers (which zero-initialize all
the fields that are not specified) over memset() where possible, and
make variable declarations local to inner scopes where applicable. One
notable exception to this rule is in the ipu3 driver, where a memset()
is needed as the structure is not a local variable but a function
parameter provided by the caller.

Not all fields of those structures can be initialized when declaring the
variables, as the values for those fields are computed later in the
code. Initialize the 'which' field in all cases, and other fields when
the variable declaration is so close to the v4l2_subdev_call() call that
it keeps all the context easily visible when reading the code, to avoid
hindering readability.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
  drivers/media/pci/cobalt/cobalt-v4l2.c        | 16 ++++++----
  drivers/media/pci/intel/ipu3/ipu3-cio2-main.c |  1 +
  .../media/platform/qcom/camss/camss-video.c   |  5 ++--
  .../media/platform/renesas/vsp1/vsp1_video.c  |  5 ++--
  .../samsung/exynos4-is/fimc-capture.c         | 11 ++++---
  .../samsung/exynos4-is/fimc-isp-video.c       | 10 +++++--
  .../platform/samsung/exynos4-is/fimc-lite.c   |  9 ++++--
  .../samsung/s3c-camif/camif-capture.c         |  5 ++--
  .../platform/samsung/s3c-camif/camif-core.c   |  5 ++--
  .../media/platform/ti/am437x/am437x-vpfe.c    | 20 +++++++------
  drivers/media/platform/ti/cal/cal-video.c     | 29 ++++++++++---------
  drivers/media/platform/ti/omap3isp/ispccdc.c  |  5 ++--
  drivers/media/platform/ti/omap3isp/ispvideo.c | 20 ++++++++-----
  drivers/media/platform/xilinx/xilinx-dma.c    |  5 ++--
  drivers/media/test-drivers/vimc/vimc-common.c |  8 ++---

For vimc

Acked-by: Shuah Khan <skhan@xxxxxxxxxxxxxxxxxxx>

thanks,
-- Shuah




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux