qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hw/net: prevent potential NULL dereference
@ 2024-05-29 11:07 Oleg Sviridov
  2024-05-29 13:52 ` Philippe Mathieu-Daudé
  2024-05-30  0:29 ` David Gibson
  0 siblings, 2 replies; 8+ messages in thread
From: Oleg Sviridov @ 2024-05-29 11:07 UTC (permalink / raw)
  To: Nicholas Piggin
  Cc: Oleg Sviridov, Daniel Henrique Barboza, David Gibson,
	Harsh Prateek Bora, Jason Wang, qemu-ppc, qemu-devel

Pointer, returned from function 'spapr_vio_find_by_reg', may be NULL and is dereferenced immediately after.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru>
---
 hw/net/spapr_llan.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/net/spapr_llan.c b/hw/net/spapr_llan.c
index ecb30b7c76..f40b733229 100644
--- a/hw/net/spapr_llan.c
+++ b/hw/net/spapr_llan.c
@@ -770,6 +770,10 @@ static target_ulong h_change_logical_lan_mac(PowerPCCPU *cpu,
     SpaprVioVlan *dev = VIO_SPAPR_VLAN_DEVICE(sdev);
     int i;
 
+    if (!dev) {
+        return H_PARAMETER;
+    }
+
     for (i = 0; i < ETH_ALEN; i++) {
         dev->nicconf.macaddr.a[ETH_ALEN - i - 1] = macaddr & 0xff;
         macaddr >>= 8;
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-01 15:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-29 11:07 [PATCH] hw/net: prevent potential NULL dereference Oleg Sviridov
2024-05-29 13:52 ` Philippe Mathieu-Daudé
2024-05-30 14:38   ` Олег Свиридов
2024-05-30  0:29 ` David Gibson
2024-05-30  9:03   ` Peter Maydell
2024-05-31  4:52     ` David Gibson
2024-05-31  7:36       ` [PATCH v2] " Oleg Sviridov
2024-07-01 15:02         ` Philippe Mathieu-Daudé

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).