diff options
author | Hans de Goede <hdegoede@redhat.com> | 2018-09-29 14:18:11 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-09-29 05:31:32 -0700 |
commit | 8568209b5445b3cc2220b3ebbcf089e9207c1745 (patch) | |
tree | efe7a49049d3d7043b9e86c4e9e0a6ff426ebae6 /drivers/staging/vboxvideo | |
parent | ca2c4bee47f8f1d03edd3dad68472abd7752e1e6 (diff) |
staging: vboxvideo: Cleanup vbox_set_up_input_mapping()
This cleanups 2 things:
1) The first time we loop over the crtc-s, to compare framebuffers, fb1 may
get set to NULL by the fb1 = CRTC_FB(crtci); statement and then we call
to_vbox_framebuffer() on it. The result of this call is only used for
an address comparison, so we don't end up dereferencing the bad pointer,
but still it is better to not do this.
2) Since we already figure out the first crtc with a fb in the first loop
and store that in fb1, there is no need to loop over the crtc-s again just
to find the first crtc with a fb again.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/vboxvideo')
-rw-r--r-- | drivers/staging/vboxvideo/vbox_mode.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/staging/vboxvideo/vbox_mode.c b/drivers/staging/vboxvideo/vbox_mode.c index bef99664d030..4f5d28aeca95 100644 --- a/drivers/staging/vboxvideo/vbox_mode.c +++ b/drivers/staging/vboxvideo/vbox_mode.c @@ -169,7 +169,7 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) { struct drm_crtc *crtci; struct drm_connector *connectori; - struct drm_framebuffer *fb1 = NULL; + struct drm_framebuffer *fb, *fb1 = NULL; bool single_framebuffer = true; bool old_single_framebuffer = vbox->single_framebuffer; u16 width = 0, height = 0; @@ -180,25 +180,25 @@ static bool vbox_set_up_input_mapping(struct vbox_private *vbox) * Same fall-back if this is the fbdev frame-buffer. */ list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, head) { + fb = CRTC_FB(crtci); + if (!fb) + continue; + if (!fb1) { - fb1 = CRTC_FB(crtci); + fb1 = fb; if (to_vbox_framebuffer(fb1) == &vbox->fbdev->afb) break; - } else if (CRTC_FB(crtci) && fb1 != CRTC_FB(crtci)) { + } else if (fb != fb1) { single_framebuffer = false; } } + if (!fb1) + return false; + if (single_framebuffer) { vbox->single_framebuffer = true; - list_for_each_entry(crtci, &vbox->ddev.mode_config.crtc_list, - head) { - if (!CRTC_FB(crtci)) - continue; - - vbox->input_mapping_width = CRTC_FB(crtci)->width; - vbox->input_mapping_height = CRTC_FB(crtci)->height; - break; - } + vbox->input_mapping_width = fb1->width; + vbox->input_mapping_height = fb1->height; return old_single_framebuffer != vbox->single_framebuffer; } /* Otherwise calculate the total span of all screens. */ |