Skip to contentSkip to conversation

watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error paths

PATCH Superseded David Disseldorp 1 participant 3 messages Mar 28, 2022 – Apr 19, 2022 VFS

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watch_queue: fix IOC_WATCH_QUEUE_SET_SIZE alloc error paths

From code inspection, the watch_queue_set_size() allocation error paths return the ret value set via the prior pipe_resize_ring() call, which will always be zero.

Fixes c73be61cede58 ("pipe: Add general notification queue support")
---
 kernel/watch_queue.c | 1 +
 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
index 3990e4df3d7b0..a128dedec9db2 100644
@@ -248,6 +248,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 	if (ret < 0)
 		goto error;
 
+	ret = -ENOMEM;
 	pages = kcalloc(sizeof(struct page *), nr_pages, GFP_KERNEL);
 	if (!pages)
 		goto error;
Signature · 1 line
2.34.1
#1 lore raw

Hi David,

Any feedback on this? It's a pretty obvious fix IMO.

Quoted 22 lines · David Disseldorp

From code inspection, the watch_queue_set_size() allocation error paths return the ret value set via the prior pipe_resize_ring() call, which will always be zero.

Fixes c73be61cede58 ("pipe: Add general notification queue support")
---
 kernel/watch_queue.c | 1 +
 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
index 3990e4df3d7b0..a128dedec9db2 100644
@@ -248,6 +248,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 	if (ret < 0)
 		goto error;
 
+	ret = -ENOMEM;
 	pages = kcalloc(sizeof(struct page *), nr_pages, GFP_KERNEL);
 	if (!pages)
 		goto error;
#2 lore raw

Ping...

Quoted 29 lines · David Disseldorp

Hi David,

Any feedback on this? It's a pretty obvious fix IMO.

Quoted 22 lines · David Disseldorp

From code inspection, the watch_queue_set_size() allocation error paths return the ret value set via the prior pipe_resize_ring() call, which will always be zero.

Fixes c73be61cede58 ("pipe: Add general notification queue support")
---
 kernel/watch_queue.c | 1 +
 1 file changed, 1 insertion(+)
kernel/watch_queue.c +1 -0
index 3990e4df3d7b0..a128dedec9db2 100644
@@ -248,6 +248,7 @@ long watch_queue_set_size(struct pipe_inode_info *pipe, unsigned int nr_notes)
 	if (ret < 0)
 		goto error;
 
+	ret = -ENOMEM;
 	pages = kcalloc(sizeof(struct page *), nr_pages, GFP_KERNEL);
 	if (!pages)
 		goto error;