staging: media: tegra-video: fix chan->mipi value on error
authorLuca Ceresoli <luca.ceresoli@bootlin.com>
Wed, 2 Nov 2022 11:01:01 +0000 (12:01 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Fri, 4 Nov 2022 15:56:38 +0000 (16:56 +0100)
commit10b5ce6743c839fa75336042c64e2479caec9430
tree0adc26f9969c300e86342ad7af3732ed16736261
parent3a04d98608a0cee98b16e6640cff6237f9a7d03d
staging: media: tegra-video: fix chan->mipi value on error

chan->mipi takes the return value of tegra_mipi_request() which can be a
valid pointer or an error. However chan->mipi is checked in several places,
including error-cleanup code in tegra_csi_channels_cleanup(), as 'if
(chan->mipi)', which suggests the initial intent was that chan->mipi should
be either NULL or a valid pointer, never an error. As a consequence,
cleanup code in case of tegra_mipi_request() errors would dereference an
invalid pointer.

Fix by ensuring chan->mipi always contains either NULL or a void pointer.

Also add that to the documentation.

Fixes: 523c857e34ce ("media: tegra-video: Add CSI MIPI pads calibration")
Cc: stable@vger.kernel.org
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/staging/media/tegra-video/csi.c
drivers/staging/media/tegra-video/csi.h