diff mbox

[intel-sgx-kernel-dev] intel_sgx: register sgx_dev with a dynamic minor

Message ID 1500576235-9494-1-git-send-email-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Sean Christopherson July 20, 2017, 6:43 p.m. UTC
The sgx device was being created with an implicit minor number of 0,
as miscdevice.minor was not being initialized.  Registering a fixed,
unofficial minor number can result in /dev/sgx being unavailable,
e.g. if another device is (also incorrectly) registered at 10,0.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 drivers/platform/x86/intel_sgx/sgx_main.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Jarkko Sakkinen Aug. 1, 2017, 1:04 p.m. UTC | #1
On Thu, Jul 20, 2017 at 11:43:55AM -0700, Sean Christopherson wrote:
> The sgx device was being created with an implicit minor number of 0,
> as miscdevice.minor was not being initialized.  Registering a fixed,
> unofficial minor number can result in /dev/sgx being unavailable,
> e.g. if another device is (also incorrectly) registered at 10,0.
> 
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>

/Jarkko

> ---
>  drivers/platform/x86/intel_sgx/sgx_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/platform/x86/intel_sgx/sgx_main.c b/drivers/platform/x86/intel_sgx/sgx_main.c
> index 8124d02..32214cd 100644
> --- a/drivers/platform/x86/intel_sgx/sgx_main.c
> +++ b/drivers/platform/x86/intel_sgx/sgx_main.c
> @@ -153,6 +153,7 @@ static const struct file_operations sgx_fops = {
>  };
>  
>  static struct miscdevice sgx_dev = {
> +	.minor	= MISC_DYNAMIC_MINOR,
>  	.name	= "sgx",
>  	.fops	= &sgx_fops,
>  	.mode   = 0666,
> -- 
> 2.7.4
> 
> _______________________________________________
> intel-sgx-kernel-dev mailing list
> intel-sgx-kernel-dev@lists.01.org
> https://lists.01.org/mailman/listinfo/intel-sgx-kernel-dev
Jarkko Sakkinen Aug. 1, 2017, 1:22 p.m. UTC | #2
On Tue, Aug 01, 2017 at 04:04:54PM +0300, Jarkko Sakkinen wrote:
> On Thu, Jul 20, 2017 at 11:43:55AM -0700, Sean Christopherson wrote:
> > The sgx device was being created with an implicit minor number of 0,
> > as miscdevice.minor was not being initialized.  Registering a fixed,
> > unofficial minor number can result in /dev/sgx being unavailable,
> > e.g. if another device is (also incorrectly) registered at 10,0.
> > 
> > Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> 
> Reviewed-by: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
> 
> /Jarkko

I applied this now to master branch.

/Jarkko

> 
> > ---
> >  drivers/platform/x86/intel_sgx/sgx_main.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/platform/x86/intel_sgx/sgx_main.c b/drivers/platform/x86/intel_sgx/sgx_main.c
> > index 8124d02..32214cd 100644
> > --- a/drivers/platform/x86/intel_sgx/sgx_main.c
> > +++ b/drivers/platform/x86/intel_sgx/sgx_main.c
> > @@ -153,6 +153,7 @@ static const struct file_operations sgx_fops = {
> >  };
> >  
> >  static struct miscdevice sgx_dev = {
> > +	.minor	= MISC_DYNAMIC_MINOR,
> >  	.name	= "sgx",
> >  	.fops	= &sgx_fops,
> >  	.mode   = 0666,
> > -- 
> > 2.7.4
> > 
> > _______________________________________________
> > intel-sgx-kernel-dev mailing list
> > intel-sgx-kernel-dev@lists.01.org
> > https://lists.01.org/mailman/listinfo/intel-sgx-kernel-dev
diff mbox

Patch

diff --git a/drivers/platform/x86/intel_sgx/sgx_main.c b/drivers/platform/x86/intel_sgx/sgx_main.c
index 8124d02..32214cd 100644
--- a/drivers/platform/x86/intel_sgx/sgx_main.c
+++ b/drivers/platform/x86/intel_sgx/sgx_main.c
@@ -153,6 +153,7 @@  static const struct file_operations sgx_fops = {
 };
 
 static struct miscdevice sgx_dev = {
+	.minor	= MISC_DYNAMIC_MINOR,
 	.name	= "sgx",
 	.fops	= &sgx_fops,
 	.mode   = 0666,