mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	fortify: test: Use kunit_device
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 <mazziesaccount@gmail.com> Acked-by: Kees Cook <keescook@chromium.org> Signed-off-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
This commit is contained in:
		
							parent
							
								
									d03c720e03
								
							
						
					
					
						commit
						46ee8f688e
					
				
					 1 changed files with 3 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -15,6 +15,7 @@
 | 
			
		|||
 */
 | 
			
		||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
 | 
			
		||||
 | 
			
		||||
#include <kunit/device.h>
 | 
			
		||||
#include <kunit/test.h>
 | 
			
		||||
#include <linux/device.h>
 | 
			
		||||
#include <linux/slab.h>
 | 
			
		||||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue