mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 03:10:12 +00:00
tilcdc: tilcdc_external: fix an incorrect NULL check on list iterator
commit8b917cbe38
upstream. The bug is here: if (!encoder) { The list iterator value 'encoder' will *always* be set and non-NULL by list_for_each_entry(), so it is incorrect to assume that the iterator value will be NULL if the list is empty or no element is found. To fix the bug, use a new variable 'iter' as the list iterator, while use the original variable 'encoder' as a dedicated pointer to point to the found element. Cc: stable@vger.kernel.org Fixes:ec9eab097a
("drm/tilcdc: Add drm bridge support for attaching drm bridge drivers") Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com> Reviewed-by: Jyri Sarha <jyri.sarha@iki.fi> Tested-by: Jyri Sarha <jyri.sarha@iki.fi> Signed-off-by: Jyri Sarha <jyri.sarha@iki.fi> Link: https://patchwork.freedesktop.org/patch/msgid/20220327061516.5076-1-xiam0nd.tong@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
dd1f20f50d
commit
8420201df3
1 changed files with 5 additions and 3 deletions
|
@ -60,11 +60,13 @@ struct drm_connector *tilcdc_encoder_find_connector(struct drm_device *ddev,
|
|||
int tilcdc_add_component_encoder(struct drm_device *ddev)
|
||||
{
|
||||
struct tilcdc_drm_private *priv = ddev->dev_private;
|
||||
struct drm_encoder *encoder;
|
||||
struct drm_encoder *encoder = NULL, *iter;
|
||||
|
||||
list_for_each_entry(encoder, &ddev->mode_config.encoder_list, head)
|
||||
if (encoder->possible_crtcs & (1 << priv->crtc->index))
|
||||
list_for_each_entry(iter, &ddev->mode_config.encoder_list, head)
|
||||
if (iter->possible_crtcs & (1 << priv->crtc->index)) {
|
||||
encoder = iter;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!encoder) {
|
||||
dev_err(ddev->dev, "%s: No suitable encoder found\n", __func__);
|
||||
|
|
Loading…
Reference in a new issue