lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 5 Oct 2020 22:58:03 +0200
From:   Pavel Machek <pavel@...x.de>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org, stable@...r.kernel.org,
        Chaitanya Kulkarni <chaitanya.kulkarni@....com>,
        Christoph Hellwig <hch@....de>, Sasha Levin <sashal@...nel.org>
Subject: Re: [PATCH 4.19 17/38] nvme-core: get/put ctrl and transport module
 in nvme_dev_open/release()

Hi!


> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
> index 33dad9774da01..9ea3d8e611005 100644
> --- a/drivers/nvme/host/core.c
> +++ b/drivers/nvme/host/core.c
> @@ -2605,10 +2605,24 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
>  		return -EWOULDBLOCK;
>  	}
>  
> +	nvme_get_ctrl(ctrl);
> +	if (!try_module_get(ctrl->ops->module))
> +		return -EINVAL;

This needs to do nvme_put_ctrl(ctrl); before returning, right?

Otherwise we leak the reference.

Plus, I'm not sure EINVAL is right error return. EBUSY?

Signed-off-by: Pavel Machek (CIP) <pavel@...x.de>

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 9ea3d8e61100..01c36f3dd87f 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -2606,8 +2606,10 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
 	}
 
 	nvme_get_ctrl(ctrl);
-	if (!try_module_get(ctrl->ops->module))
-		return -EINVAL;
+	if (!try_module_get(ctrl->ops->module)) {
+		nvme_put_ctrl(ctrl);
+		return -EBUSY;
+	}
 
 	file->private_data = ctrl;
 	return 0;


-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ