[PATCH] ui/spice-display: check NULL pointer in interface_release_resource()

Mauro Matteo Cascella posted 1 patch 2 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/next-importer-push tags/patchew/20210520105833.183160-1-mcascell@redhat.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
ui/spice-display.c | 4 ++++
1 file changed, 4 insertions(+)
[PATCH] ui/spice-display: check NULL pointer in interface_release_resource()
Posted by Mauro Matteo Cascella 2 years, 11 months ago
Check rext.info to avoid potential NULL pointer dereference. A similar check
exists in interface_release_resource() in hw/display/qxl.c.

Reported-by: Yu Lu <ini.universe@gmail.com>
Signed-off-by: Mauro Matteo Cascella <mcascell@redhat.com>
---
 ui/spice-display.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/ui/spice-display.c b/ui/spice-display.c
index d22781a23d..f59c69882d 100644
--- a/ui/spice-display.c
+++ b/ui/spice-display.c
@@ -561,6 +561,10 @@ static void interface_release_resource(QXLInstance *sin,
     SimpleSpiceCursor *cursor;
     QXLCommandExt *ext;
 
+    if (!rext.info) {
+        return;
+    }
+
     ext = (void *)(intptr_t)(rext.info->id);
     switch (ext->cmd.type) {
     case QXL_CMD_DRAW:
-- 
2.31.1


Re: [PATCH] ui/spice-display: check NULL pointer in interface_release_resource()
Posted by P J P 2 years, 11 months ago
+-- On Thu, 20 May 2021, Mauro Matteo Cascella wrote --+
| diff --git a/ui/spice-display.c b/ui/spice-display.c
| index d22781a23d..f59c69882d 100644
| --- a/ui/spice-display.c
| +++ b/ui/spice-display.c
| @@ -561,6 +561,10 @@ static void interface_release_resource(QXLInstance *sin,
|      SimpleSpiceCursor *cursor;
|      QXLCommandExt *ext;
|  
| +    if (!rext.info) {
| +        return;
| +    }
| +
|      ext = (void *)(intptr_t)(rext.info->id);
|      switch (ext->cmd.type) {
|      case QXL_CMD_DRAW:

Looks okay.

Reviewed-by: Prasad J Pandit <pjp@fedoraproject.org>

Thank you.
--
 - P J P
8685 545E B54C 486B C6EB 271E E285 8B5A F050 DE8D