From nobody Sat Feb 7 15:12:16 2026 Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D1512FE577 for ; Mon, 5 Jan 2026 07:14:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767597293; cv=none; b=i8t99VvhguVKXGN60ujTwi27VkaTs98al6bVsnol7j3ka3ejdSVYbf0LdJPMfiWPPGb8R3bn7LJRBRF/wTlnDS4/g7A/yBDl7xTtIgGs26bvScTigBQNYJlWGcs98+6iaNFAnbKu4TDJmh1XZvdIT547ipH1Yqu4GTqQAAvarD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767597293; c=relaxed/simple; bh=Qz2RwYF5op0fgZk+kqY/IBcQu5bf9JLkopGyU2Lh5pw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=mpXZfuegd1WZ5o4OH83kDfNOutpnEbrS9r8o2X1973fYt4UmKwr0TNmHSsawGo/b0Vqxw56W0tKXHVbdBrEuJq8l1Lx3lhTCy0Ks3wr2Abuz3NkuHqYSJewGAS4rnRbEsSNA/kirx2LNSzO5IMxDFa3U/YUtPNKF+zRBbfoeTLg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OfaUhey8; arc=none smtp.client-ip=209.85.216.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OfaUhey8" Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-34c1d84781bso14993220a91.2 for ; Sun, 04 Jan 2026 23:14:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767597291; x=1768202091; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eUHw25NGQsrcl9rOD/QRFS39Fxhsx8ixc4+FBk8HjuM=; b=OfaUhey8//7Nsv77+vGc0hZoilphxlqcYd7EPBdDQpRo1/6NgKq5yYCFVqOxyW0krJ EOtaywKwEihIrCdbSwUPk7RqlzRShOVs/Nza0gTj4WAxW0RaqtgBNwqRQ9xwepivYZk8 1MnAi6Qg2E+7gX4s9N891FkkJzC7g4hM8967Iy/EcRjuAQqJrkrSYLXlg/yJ5znZ8aC2 rHpEIi8UUrF2XLhkg+5Uzhfsids0QRHU8YJUv2gMsuL7dGRpOZ8miuXvIt8T+7Tz1oHj ZqSG292RmclCKOzyPbskxZgMGoXMwlSGKqie1QkSa1TWr8QJuSaD4dV9sHiowRjjWBB7 mGJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767597291; x=1768202091; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=eUHw25NGQsrcl9rOD/QRFS39Fxhsx8ixc4+FBk8HjuM=; b=dbIj+zEy8LkhUVnNp9hOsKolaN/zw+pgUoILZyom2nJCZtCd8E89lgMa2AJ07RI4F2 7kWZEQx3MEok8g2DUVZoNIjJvrx+O+bPVXXpbImaH8QUDsAArxC+N4VvI+iNvAi1xlz2 QtoMdF2EsvZFEJT1gFZ8Lsq+g2cdmkbrIQKyKOIqsqhlokets/4g+SZ9D+eHkQQMF4GF XJa54UoOlXvl4hXTFcnhmC3N/0ZatNTk/oOdTZ3wJrCTBYYJguDpSFE/WIZ0RpSDSkYc R6/JoE/yNOJO6WLhs6lzjmnPl+/DOzd2c4Qnjc2s7/gLcR0P0ZfnyCDXvPEyCtXlmCEf a8VQ== X-Forwarded-Encrypted: i=1; AJvYcCU5a0UhBoUefw8RO+Z187tGrSwzM5JTRIzRyjHwb0q+liLr9CtWcapctZUHeszjAyttmQwSXr0HjfEkCcY=@vger.kernel.org X-Gm-Message-State: AOJu0YyMRb3U6uKHBqSiXEkKLH2jzGTpF0J9I9HqQ2VL+eMwiUW4zaWs Uz4GlulIEHO8C0X9SzBCofsU19OhkHGbQVo9i3rCpp7A0e9nkOvHeaG3 X-Gm-Gg: AY/fxX543qcbugeUEgOUnNLukp5YPV7hLJEJNsxXcT3pCsC0mGYmqI1kDdIytRpQZiB ZEeFrKUJZJ5uxKwNPGwYQFI/6B/7PFriSHETJBwy8FaZIJFsDOEV9oUrdjc2Tu+ft2bv/Pejvco alvi9f44Z59RQ2G3B85V3Bxk+3wIwMcyoWB+281L53A2se1b8qM1yJdrkPZF11NpWQa8obQQUfZ viLeLVzy9QVMknxlLMiOGeflAG+lFXCtL9Wa1+K/GnGi71YCaPx4OdV5sAWntFTc8VwH7fzhhD8 2HAgK+s2WnDjMpBRZ/xQc6Yhq7R8HL0Ypv4IyQmBuvW/cu2JqoamNSTFos3Z0rV2E60BwLnHhDh J7ulZ5eT1ULRz5qz8JPC1vNwmvXVamzIzhE5cB10jqtpFxqsuXPaUsQkAyaL+TBzAwc7Ruxo= X-Google-Smtp-Source: AGHT+IFe4WIaO9ozYXfXHaY7XO3a8e595bEIqJaMyR/ooPGGBnr8tW0YWRKmtUn1G3EzDuvJwJUqvQ== X-Received: by 2002:a17:90a:dfc6:b0:340:d1a1:af8e with SMTP id 98e67ed59e1d1-34e921e60d9mr42814526a91.37.1767597291434; Sun, 04 Jan 2026 23:14:51 -0800 (PST) Received: from oslab.. ([2402:f000:4:1006:809:0:a77:18ea]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7b31c479sm46996054b3a.24.2026.01.04.23.14.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 23:14:51 -0800 (PST) From: Tuo Li To: robh@kernel.org, saravanak@google.com Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Tuo Li Subject: [PATCH] of: unittest: fix possible null-pointer dereferences in of_unittest_property_copy() Date: Mon, 5 Jan 2026 15:14:38 +0800 Message-ID: <20260105071438.156186-1-islituo@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This function first duplicates p1 and p2 into new, and then checks whether the duplication succeeds. However, if the duplication fails (e.g.,=20 kzalloc() returns NULL in __of_prop_dup()), new will be NULL but is still dereferenced in __of_prop_free(). To ensure that the unit test continues to run even when duplication fails, add a NULL check before calling=20 __of_prop_free(). Fixes: 1c5e3d9bf33b ("of: Add a helper to free property struct") Signed-off-by: Tuo Li --- drivers/of/unittest.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 388e9ec2cccf..ea650a9ca2d9 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -804,11 +804,13 @@ static void __init of_unittest_property_copy(void) =20 new =3D __of_prop_dup(&p1, GFP_KERNEL); unittest(new && propcmp(&p1, new), "empty property didn't copy correctly\= n"); - __of_prop_free(new); + if (new) + __of_prop_free(new); =20 new =3D __of_prop_dup(&p2, GFP_KERNEL); unittest(new && propcmp(&p2, new), "non-empty property didn't copy correc= tly\n"); - __of_prop_free(new); + if (new) + __of_prop_free(new); #endif } =20 --=20 2.43.0