From patchwork Fri Dec 8 10:09:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 13485142 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="VDr9tcj4" Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4BB91736 for ; Fri, 8 Dec 2023 02:09:57 -0800 (PST) Received: by mail-yb1-xb49.google.com with SMTP id 3f1490d57ef6-daee86e2d70so2584296276.0 for ; Fri, 08 Dec 2023 02:09:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702030197; x=1702634997; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=vJ3XYd4VAh0rMwZdPZnf0/R4/jXxDQ1RiH7pfcHiYc8=; b=VDr9tcj4StnA6acjRdrtszhpigA+LyEHfIwbdwp5vEDSLyQ2c06X0f1qayIhI8+EAM r6FhkDaaKJDAFG2WPAqaLSFgFJYgJTQmwSinohvw6fX9JU05gn1piF4HSMp1QyjuD+hc LlgfLm9xm/qiGoZ+JYDrryT6EFNdLOCNWFYWUNJJIkjz86006ehBfhgbvosPV1O4WBPU ABaqxj2OzKfF8pO28M7kbucpENFfkZVMQ+R/GvWK0j/oeVPrTz99IIeQ5nRoaxIhWa7G qQ5dED3iTrJbm5hEMRwp3R0L563dY3XUizJ0DaECRNx5LvnFnzhjznIrwqajOL4Tp+9H x8eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702030197; x=1702634997; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=vJ3XYd4VAh0rMwZdPZnf0/R4/jXxDQ1RiH7pfcHiYc8=; b=U+KLCU+QZvsA4vZ3NyF9TxFm+qhru4w7ml1AESwENoDnAHgeO0W6aoQb8Q7fx3uu1E iSFkpcSq8atPztiqw7trtU/36UEFge6564IUxmrNIh1rLN/tgTAvcsp/ZgA2m2dcnzSL OwmgAPnQozI6xCa5IUEf46dMnCY/fXi9Nj0JoGWUJAx6l9ZdOiEv5j6AgbyuYNihyf6x tLnKMThAOSrHXdGZG4cSprmbqr3M/EpkYzx2qsNAVBb+y66owRr/Z1tsFiqpHerNdwyg Q8cIL8HuD4ZlzAzbCEySOvDENR6B362GjncYrZGnBiTfa39xRbiSyDfQrjvUm/cdQ/3+ GbtA== X-Gm-Message-State: AOJu0YxtiavAXTds3c79aIR4Gus4hSXEqZduf8f3xkn3MHMivapSkogq C6NAN8B6UihhJqCQryYLoDUaCoHQekwcpw== X-Google-Smtp-Source: AGHT+IEoLvJsRYtYBtpiMYYBRwRZCWLln+T0Te5bpJ5ZhKJL6iGz1n9WIFhdhIvRsrqNCPNn+H/9E0PqoIsEoA== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a25:fc12:0:b0:dbc:1b65:fd8c with SMTP id v18-20020a25fc12000000b00dbc1b65fd8cmr43469ybd.5.1702030196750; Fri, 08 Dec 2023 02:09:56 -0800 (PST) Date: Fri, 08 Dec 2023 18:09:30 +0800 In-Reply-To: <20231208-kunit_bus-v2-0-e95905d9b325@google.com> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20231208-kunit_bus-v2-0-e95905d9b325@google.com> X-Mailer: b4 0.13-dev-099c9 Message-ID: <20231208-kunit_bus-v2-2-e95905d9b325@google.com> Subject: [PATCH v2 2/4] fortify: test: Use kunit_device From: davidgow@google.com To: Rae Moar , Brendan Higgins , Greg Kroah-Hartman , Matti Vaittinen , Stephen Boyd , Shuah Khan , Jonathan Corbet , Kees Cook , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Maxime Ripard Cc: linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-sound@vger.kernel.org, David Gow Using struct root_device to create fake devices for tests is something of a hack. The new struct kunit_device is meant for this purpose, so use it instead. Reviewed-by: Matti Vaittinen Acked-by: Kees Cook Signed-off-by: David Gow --- lib/fortify_kunit.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fortify_kunit.c b/lib/fortify_kunit.c index c8c33cbaae9e..2e4fedc81621 100644 --- a/lib/fortify_kunit.c +++ b/lib/fortify_kunit.c @@ -15,6 +15,7 @@ */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt +#include #include #include #include @@ -269,7 +270,7 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc) size_t len; \ \ /* Create dummy device for devm_kmalloc()-family tests. */ \ - dev = root_device_register(dev_name); \ + dev = kunit_device_register(test, dev_name); \ KUNIT_ASSERT_FALSE_MSG(test, IS_ERR(dev), \ "Cannot register test device\n"); \ \ @@ -303,7 +304,7 @@ DEFINE_ALLOC_SIZE_TEST_PAIR(kvmalloc) checker(len, devm_kmemdup(dev, "Ohai", len, gfp), \ devm_kfree(dev, p)); \ \ - device_unregister(dev); \ + kunit_device_unregister(test, dev); \ } while (0) DEFINE_ALLOC_SIZE_TEST_PAIR(devm_kmalloc)