Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(542)

Side by Side Diff: ui/ozone/platform/drm/gpu/screen_manager.cc

Issue 1072383003: ozone: drm: Fix HardwareDisplayController use-after-free (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/drm/gpu/screen_manager.h" 5 #include "ui/ozone/platform/drm/gpu/screen_manager.h"
6 6
7 #include <xf86drmMode.h> 7 #include <xf86drmMode.h>
8 8
9 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/geometry/point.h" 10 #include "ui/gfx/geometry/point.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 controllers_.push_back(new HardwareDisplayController( 91 controllers_.push_back(new HardwareDisplayController(
92 scoped_ptr<CrtcController>(new CrtcController(drm, crtc, connector)))); 92 scoped_ptr<CrtcController>(new CrtcController(drm, crtc, connector))));
93 } 93 }
94 94
95 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm, 95 void ScreenManager::RemoveDisplayController(const scoped_refptr<DrmDevice>& drm,
96 uint32_t crtc) { 96 uint32_t crtc) {
97 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc); 97 HardwareDisplayControllers::iterator it = FindDisplayController(drm, crtc);
98 if (it != controllers_.end()) { 98 if (it != controllers_.end()) {
99 bool is_mirrored = (*it)->IsMirrored(); 99 bool is_mirrored = (*it)->IsMirrored();
100 (*it)->RemoveCrtc(drm, crtc); 100 (*it)->RemoveCrtc(drm, crtc);
101 if (!is_mirrored) { 101 if (!is_mirrored)
102 UpdateControllerToWindowMapping(); 102 RemoveController(it);
103 controllers_.erase(it);
alexst (slow to review) 2015/04/15 00:50:02 I want to say there was a reason why this was remo
spang 2015/04/15 02:12:11 I don't think we are intentionally invoking UB and
dnicoara 2015/04/15 13:43:41 Yeah, order is messed up.
104 }
105 } 103 }
106 } 104 }
107 105
108 bool ScreenManager::ConfigureDisplayController( 106 bool ScreenManager::ConfigureDisplayController(
109 const scoped_refptr<DrmDevice>& drm, 107 const scoped_refptr<DrmDevice>& drm,
110 uint32_t crtc, 108 uint32_t crtc,
111 uint32_t connector, 109 uint32_t connector,
112 const gfx::Point& origin, 110 const gfx::Point& origin,
113 const drmModeModeInfo& mode) { 111 const drmModeModeInfo& mode) {
114 bool status = 112 bool status =
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 } 275 }
278 276
279 bool ScreenManager::HandleMirrorMode( 277 bool ScreenManager::HandleMirrorMode(
280 HardwareDisplayControllers::iterator original, 278 HardwareDisplayControllers::iterator original,
281 HardwareDisplayControllers::iterator mirror, 279 HardwareDisplayControllers::iterator mirror,
282 const scoped_refptr<DrmDevice>& drm, 280 const scoped_refptr<DrmDevice>& drm,
283 uint32_t crtc, 281 uint32_t crtc,
284 uint32_t connector) { 282 uint32_t connector) {
285 (*mirror)->AddCrtc((*original)->RemoveCrtc(drm, crtc)); 283 (*mirror)->AddCrtc((*original)->RemoveCrtc(drm, crtc));
286 if ((*mirror)->Enable()) { 284 if ((*mirror)->Enable()) {
287 controllers_.erase(original); 285 RemoveController(original);
dnicoara 2015/04/15 13:43:41 This will cause UpdateControllerToWindowMapping()
spang 2015/04/15 13:48:24 Done.
288 return true; 286 return true;
289 } 287 }
290 288
291 LOG(ERROR) << "Failed to switch to mirror mode"; 289 LOG(ERROR) << "Failed to switch to mirror mode";
292 290
293 // When things go wrong revert back to the previous configuration since 291 // When things go wrong revert back to the previous configuration since
294 // it is expected that the configuration would not have changed if 292 // it is expected that the configuration would not have changed if
295 // things fail. 293 // things fail.
296 (*original)->AddCrtc((*mirror)->RemoveCrtc(drm, crtc)); 294 (*original)->AddCrtc((*mirror)->RemoveCrtc(drm, crtc));
297 (*original)->Enable(); 295 (*original)->Enable();
(...skipping 28 matching lines...) Expand all
326 324
327 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const { 325 DrmWindow* ScreenManager::FindWindowAt(const gfx::Rect& bounds) const {
328 for (auto pair : window_map_) { 326 for (auto pair : window_map_) {
329 if (pair.second->bounds() == bounds) 327 if (pair.second->bounds() == bounds)
330 return pair.second; 328 return pair.second;
331 } 329 }
332 330
333 return nullptr; 331 return nullptr;
334 } 332 }
335 333
334 void ScreenManager::RemoveController(
335 HardwareDisplayControllers::iterator controller) {
336 controllers_.erase(controller);
337 UpdateControllerToWindowMapping();
338 }
339
336 } // namespace ui 340 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/drm/gpu/screen_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698