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>] [day] [month] [year] [list]
Message-ID: <20210519141658.3063287-1-weiyongjun1@huawei.com>
Date:   Wed, 19 May 2021 14:16:58 +0000
From:   Wei Yongjun <weiyongjun1@...wei.com>
To:     <weiyongjun1@...wei.com>, David Howells <dhowells@...hat.com>,
        "Jarkko Sakkinen" <jarkko@...nel.org>,
        Lukas Bulwahn <lukas.bulwahn@...il.com>
CC:     <linux-kernel@...r.kernel.org>, Hulk Robot <hulkci@...wei.com>
Subject: [PATCH -next] watch_queue: Fix error return code in watch_queue_set_size()

Fix to return negative error code -ENOMEM from the alloc failed error
handling cases instead of 0, as done elsewhere in this function.

Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Wei Yongjun <weiyongjun1@...wei.com>
---
 kernel/watch_queue.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/kernel/watch_queue.c b/kernel/watch_queue.c
index 9c9eb20dd2c5..35e03b1bfadd 100644
--- a/kernel/watch_queue.c
+++ b/kernel/watch_queue.c
@@ -248,21 +248,27 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 		goto error;
 
 	pages = kcalloc(sizeof(struct page *), nr_pages, GFP_KERNEL);
-	if (!pages)
+	if (!pages) {
+		ret = -ENOMEM;
 		goto error;
+	}
 
 	for (i = 0; i < nr_pages; i++) {
 		pages[i] = alloc_page(GFP_KERNEL);
-		if (!pages[i])
+		if (!pages[i]) {
+			ret = -ENOMEM;
 			goto error_p;
+		}
 		pages[i]->index = i * WATCH_QUEUE_NOTES_PER_PAGE;
 	}
 
 	bmsize = (nr_notes + BITS_PER_LONG - 1) / BITS_PER_LONG;
 	bmsize *= sizeof(unsigned long);
 	bitmap = kmalloc(bmsize, GFP_KERNEL);
-	if (!bitmap)
+	if (!bitmap) {
+		ret = -ENOMEM;
 		goto error_p;
+	}
 
 	memset(bitmap, 0xff, bmsize);
 	wqueue->notes = pages;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ