On 10/7/25 16:48, Peter Maydell wrote:
On Mon, 10 Feb 2025 at 12:10, Philippe Mathieu-Daudé <phi...@linaro.org> wrote:

Coverity reported a unnecessary NULL check:

   qemu/system/qdev-monitor.c: 720 in qdev_device_add_from_qdict()
   683     /* create device */
   684     dev = qdev_new(driver);
   ...
   719     err_del_dev:
   >>>     CID 1590192:  Null pointer dereferences  (REVERSE_INULL)
   >>>     Null-checking "dev" suggests that it may be null, but it has already 
been dereferenced on all paths leading to the check.
   720         if (dev) {
   721             object_unparent(OBJECT(dev));
   722             object_unref(OBJECT(dev));
   723         }
   724         return NULL;
   725     }

Indeed, unlike qdev_try_new() which can return NULL,
qdev_new() always returns a heap pointer (or aborts).

Remove the unnecessary assignment and check.

Fixes: f3a85056569 ("qdev/qbus: add hidden device support")
Resolves: Coverity CID 1590192 (Null pointer dereferences)
Suggested-by: Peter Maydell <peter.mayd...@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>

Looks like this got reviewed but never picked up by anybody.
I'll add it to my target-arm.next tree.

Thanks!


Reply via email to