mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	The override status function needs to be updated to use the proper
request parameter in order to get the security state.
Fixes: 3c13e2ac74 ("...Add test support for Intel nvdimm security DSMs")
Reported-by: Vishal Verma <vishal.l.verma@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
		
	
			
		
			
				
	
	
		
			41 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
	
		
			1 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
// SPDX-License-Identifier: GPL-2.0
 | 
						|
/* Copyright Intel Corp. 2018 */
 | 
						|
#include <linux/init.h>
 | 
						|
#include <linux/module.h>
 | 
						|
#include <linux/moduleparam.h>
 | 
						|
#include <linux/nd.h>
 | 
						|
#include "pmem.h"
 | 
						|
#include "pfn.h"
 | 
						|
#include "nd.h"
 | 
						|
#include "nd-core.h"
 | 
						|
 | 
						|
ssize_t security_show(struct device *dev,
 | 
						|
		struct device_attribute *attr, char *buf)
 | 
						|
{
 | 
						|
	struct nvdimm *nvdimm = to_nvdimm(dev);
 | 
						|
 | 
						|
	/*
 | 
						|
	 * For the test version we need to poll the "hardware" in order
 | 
						|
	 * to get the updated status for unlock testing.
 | 
						|
	 */
 | 
						|
	nvdimm->sec.state = nvdimm_security_state(nvdimm, NVDIMM_USER);
 | 
						|
	nvdimm->sec.ext_state = nvdimm_security_state(nvdimm, NVDIMM_MASTER);
 | 
						|
 | 
						|
	switch (nvdimm->sec.state) {
 | 
						|
	case NVDIMM_SECURITY_DISABLED:
 | 
						|
		return sprintf(buf, "disabled\n");
 | 
						|
	case NVDIMM_SECURITY_UNLOCKED:
 | 
						|
		return sprintf(buf, "unlocked\n");
 | 
						|
	case NVDIMM_SECURITY_LOCKED:
 | 
						|
		return sprintf(buf, "locked\n");
 | 
						|
	case NVDIMM_SECURITY_FROZEN:
 | 
						|
		return sprintf(buf, "frozen\n");
 | 
						|
	case NVDIMM_SECURITY_OVERWRITE:
 | 
						|
		return sprintf(buf, "overwrite\n");
 | 
						|
	default:
 | 
						|
		return -ENOTTY;
 | 
						|
	}
 | 
						|
 | 
						|
	return -ENOTTY;
 | 
						|
}
 | 
						|
 |