[Spice-devel,qxl-wddm-dod] Avoid assert printout upon fallback of memory allocation

Submitted by Yuri Benditovich on April 12, 2017, 1:26 p.m.

Details

Message ID 1492003590-15092-1-git-send-email-yuri.benditovich@daynix.com
State New
Headers show
Series "Avoid assert printout upon fallback of memory allocation" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Yuri Benditovich April 12, 2017, 1:26 p.m.
If the memory was requested from VRAM area but finally allocated
from DEVRAM, set memory space variable for correct verification
of allocated pointer

Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>
---
 qxldod/QxlDod.cpp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
index 813ab44..746f53e 100755
--- a/qxldod/QxlDod.cpp
+++ b/qxldod/QxlDod.cpp
@@ -4077,8 +4077,11 @@  void *QxlDevice::AllocMem(UINT32 mspace_type, size_t size, BOOL force)
         FlushReleaseRing();
 
         ptr = mspace_malloc(m_MSInfo[mspace_type]._mspace, size);
-        if (!ptr && mspace_type == MSPACE_TYPE_VRAM)
-            ptr = mspace_malloc(m_MSInfo[MSPACE_TYPE_DEVRAM]._mspace, size);
+        if (!ptr && mspace_type == MSPACE_TYPE_VRAM &&
+            (ptr = mspace_malloc(m_MSInfo[MSPACE_TYPE_DEVRAM]._mspace, size))) {
+            /* for proper address check at the end of the procedure */
+            mspace_type = MSPACE_TYPE_DEVRAM;
+        }
         if (ptr) {
             break;
         }

Comments

> 
> If the memory was requested from VRAM area but finally allocated
> from DEVRAM, set memory space variable for correct verification
> of allocated pointer
> 
> Signed-off-by: Yuri Benditovich <yuri.benditovich@daynix.com>

acked

Frediano

> ---
>  qxldod/QxlDod.cpp | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/qxldod/QxlDod.cpp b/qxldod/QxlDod.cpp
> index 813ab44..746f53e 100755
> --- a/qxldod/QxlDod.cpp
> +++ b/qxldod/QxlDod.cpp
> @@ -4077,8 +4077,11 @@ void *QxlDevice::AllocMem(UINT32 mspace_type, size_t
> size, BOOL force)
>          FlushReleaseRing();
>  
>          ptr = mspace_malloc(m_MSInfo[mspace_type]._mspace, size);
> -        if (!ptr && mspace_type == MSPACE_TYPE_VRAM)
> -            ptr = mspace_malloc(m_MSInfo[MSPACE_TYPE_DEVRAM]._mspace, size);
> +        if (!ptr && mspace_type == MSPACE_TYPE_VRAM &&
> +            (ptr = mspace_malloc(m_MSInfo[MSPACE_TYPE_DEVRAM]._mspace,
> size))) {
> +            /* for proper address check at the end of the procedure */
> +            mspace_type = MSPACE_TYPE_DEVRAM;
> +        }
>          if (ptr) {
>              break;
>          }