Skip to content

Commit

Permalink
ozone: Fix a nullptr access if a bo can't be created
Browse files Browse the repository at this point in the history
GbmBuffer tries to access a nullptr after gbm_bo_create returns
null.
This patch makes sure to return a nullptr when this happens.

This seems to be the already intended behavior since after dereferencing
the nullptr we already check if it's null, and return nullptr in that case.

Bug: 751334
Change-Id: I620e099bd52b33c9f43b25c774243f93f47f5bc5
Reviewed-on: https://chromium-review.googlesource.com/609189
Reviewed-by: David Reveman <reveman@chromium.org>
Commit-Queue: Daniele Castagna <dcastagna@chromium.org>
Cr-Commit-Position: refs/heads/master@{#493295}
  • Loading branch information
DCastagna authored and Commit Bot committed Aug 10, 2017
1 parent 7e3b389 commit 554a3d4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ui/ozone/platform/drm/gpu/gbm_buffer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,7 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferForBO(
uint32_t flags,
uint64_t modifier,
uint32_t addfb_flags) {
if (!bo)
return nullptr;

DCHECK(bo);
std::vector<base::ScopedFD> fds;
std::vector<gfx::NativePixmapPlane> planes;

Expand Down Expand Up @@ -222,6 +220,8 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBufferWithModifiers(
gbm_bo* bo =
gbm_bo_create_with_modifiers(gbm->device(), size.width(), size.height(),
format, modifiers.data(), modifiers.size());
if (!bo)
return nullptr;

return CreateBufferForBO(gbm, bo, format, size, flags,
gbm_bo_get_format_modifier(bo),
Expand All @@ -239,6 +239,8 @@ scoped_refptr<GbmBuffer> GbmBuffer::CreateBuffer(

gbm_bo* bo =
gbm_bo_create(gbm->device(), size.width(), size.height(), format, flags);
if (!bo)
return nullptr;

return CreateBufferForBO(gbm, bo, format, size, flags,
gbm_bo_get_format_modifier(bo), 0);
Expand Down

0 comments on commit 554a3d4

Please sign in to comment.