From patchwork Mon Jan 29 19:25:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Christian A. Ehrhardt" X-Patchwork-Id: 193676 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp786783dyb; Mon, 29 Jan 2024 11:30:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IGIQE2NMG9cTJ/vjHtII/bMb9CDUh5vztjRz5oZhOU8r2Mb5q4VNUOxL+76GcoK6n/b5H/l X-Received: by 2002:a17:902:d48e:b0:1d8:b2d2:49dd with SMTP id c14-20020a170902d48e00b001d8b2d249ddmr3188404plg.58.1706556628965; Mon, 29 Jan 2024 11:30:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706556628; cv=pass; d=google.com; s=arc-20160816; b=pCfpxWDbgRmOfJb9onpM05fCvXyNJ2oMRmOFLrKgmuF7BXvskIU5gnqGs/WOA5tyuB tujxvPDq8Sxuw2u8GzYxTBInWLnEz7pj5aRZnEP1UIrPo5inyCXojIm7fzAVGyWRcHjx bDj0M+UW/qw4qNiaFgEB9jtRo3QYTd1/eLOireR2Sq9yYVMqd4g83AFTpWI2ATpFQroT W4yM973+0I6Vv7flJu8HO1FgCsdRWIoUgImWD8iT6bh5oimaQ9GUVt/Mi3ONoi02uQ2A OmDNwJt74cJvdeJOOmJXLU0ZRPb8yJpevI7inVbbyOquMwy3WurH5MAqEDRkth7Io3OY Qj4A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=OsEdJgLEN5Z5SeXnBuQASUfQNAs6I7xh5ImcvlP6N+Q=; fh=JqWV4oJtdaN/lYyjmxqgSHbS8hPFBO5aOW6fMWBQKQI=; b=sDgWptMjdOSRbi1F/JlPUOWF0RuyxGiCAAJUqtCxWGwCifth6b4qcHW6vFoC0XPg7k bLqw/xiopzKLzG+8ADs3M9ZhgD1NyJNRca3tSPDrnI0pW98T4cw50VyUmNjLut9wIoGQ qZ0pJlO/+3/5jj2NFQzl9C9pksEvdP0cd4bXz+iyHdhTh9kQZzT6FXop8PkN4B1aFxd+ ju1tXsUWnrRuNpxP2h/Nlp4PPajPSO7BgkfDEVNCDYqUvc6baAs9W5xUnUe4nyCp+RUX hYaCKuGedW2C3NiC1WmTiklISiCelYxY+NIewXZc2d7nkPsDVFh7rvlZWVHNcgISWsVW 8gjw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-43398-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43398-ouuuleilei=gmail.com@vger.kernel.org" Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id f7-20020a170902860700b001d74823fc26si5938280plo.583.2024.01.29.11.30.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 11:30:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43398-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=c--e.de); spf=pass (google.com: domain of linux-kernel+bounces-43398-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43398-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 7CBE4B232D2 for ; Mon, 29 Jan 2024 19:26:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CFDF16F08C; Mon, 29 Jan 2024 19:26:11 +0000 (UTC) Received: from cae.in-ulm.de (cae.in-ulm.de [217.10.14.231]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0AA5D48790; Mon, 29 Jan 2024 19:26:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.10.14.231 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706556370; cv=none; b=vCr+dPTpjPWtzf/IMFjXsN/0dMR8GB4DVJfef5ynx80QPLjJ8yWc8xXy8GP8bAosXDRXwKAXHxk+zLAh/drnSgMPCer2C+isCVtI1RSIkscCjKA5qRl/1G3YewzktFdW2eIS9xJd+bsfzDS7l6c4ZoFm91rDUveonxEKvlwYJWU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706556370; c=relaxed/simple; bh=0H1efk1aVnyuVpbUEA9SC32klBbFqrS01WqXHiiHmPw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=cB+b5N1FB5gST2jcBrl/1XoVTkF7NVcYErEc6Da8mRhQu0X5fOqs0XdnkbYQvwDJr0efgqYJc7i46nemBJW06YTo1ilK+aW+8H6CnMzJgJJv1OhhBLoAIPKlvUlFHYPyhyhwLrGycu5VzupKwZB7kY46VzmM1A0u8/CCN6d8bH0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de; spf=pass smtp.mailfrom=c--e.de; arc=none smtp.client-ip=217.10.14.231 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=c--e.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=c--e.de Received: by cae.in-ulm.de (Postfix, from userid 1000) id EF0A11402D8; Mon, 29 Jan 2024 20:26:06 +0100 (CET) From: "Christian A. Ehrhardt" To: devicetree@vger.kernel.org Cc: "Christian A. Ehrhardt" , kernel test robot , Rob Herring , Frank Rowand , linux-kernel@vger.kernel.org Subject: [PATCH] of: unittest: Fix compile in the non-dynamic case Date: Mon, 29 Jan 2024 20:25:56 +0100 Message-Id: <20240129192556.403271-1-lk@c--e.de> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789454323726689691 X-GMAIL-MSGID: 1789454323726689691 If CONFIG_OF_KOBJ is not set, a device_node does not contain a kobj and attempts to access the embedded kobj via kref_read break the compile. Replace affected kref_read calls with a macro that reads the refcount if it exists and returns 1 if there is no embedded kobj. Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401291740.VP219WIz-lkp@intel.com/ Fixes: 4dde83569832 ("of: Fix double free in of_parse_phandle_with_args_map") Signed-off-by: Christian A. Ehrhardt --- drivers/of/unittest.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index cfd60e35a899..d7593bde2d02 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -50,6 +50,12 @@ static struct unittest_results { failed; \ }) +#ifdef CONFIG_OF_KOBJ +#define OF_KREF_READ(NODE) kref_read(&(NODE)->kobj.kref) +#else +#define OF_KREF_READ(NODE) 1 +#endif + /* * Expected message may have a message level other than KERN_INFO. * Print the expected message only if the current loglevel will allow @@ -570,7 +576,7 @@ static void __init of_unittest_parse_phandle_with_args_map(void) pr_err("missing testcase data\n"); return; } - prefs[i] = kref_read(&p[i]->kobj.kref); + prefs[i] = OF_KREF_READ(p[i]); } rc = of_count_phandle_with_args(np, "phandle-list", "#phandle-cells"); @@ -693,9 +699,9 @@ static void __init of_unittest_parse_phandle_with_args_map(void) unittest(rc == -EINVAL, "expected:%i got:%i\n", -EINVAL, rc); for (i = 0; i < ARRAY_SIZE(p); ++i) { - unittest(prefs[i] == kref_read(&p[i]->kobj.kref), + unittest(prefs[i] == OF_KREF_READ(p[i]), "provider%d: expected:%d got:%d\n", - i, prefs[i], kref_read(&p[i]->kobj.kref)); + i, prefs[i], OF_KREF_READ(p[i])); of_node_put(p[i]); } }