Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1643573 > unrolled thread

[PATCH] CIFS: check if pages is null rather than bv for a failed allocation

Started byColin King <colin.king@canonical.com>
First post2017-05-17 20:30 +0200
Last post2017-05-17 22:10 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] CIFS: check if pages is null rather than bv for a failed allocation Colin King <colin.king@canonical.com> - 2017-05-17 20:30 +0200
    Re: [PATCH] CIFS: check if pages is null rather than bv for a failed allocation Pavel Shilovsky <piastryyy@gmail.com> - 2017-05-17 22:10 +0200

#1643573 — [PATCH] CIFS: check if pages is null rather than bv for a failed allocation

FromColin King <colin.king@canonical.com>
Date2017-05-17 20:30 +0200
Subject[PATCH] CIFS: check if pages is null rather than bv for a failed allocation
Message-ID<tIbRU-6Bk-5@gated-at.bofh.it>
From: Colin Ian King <colin.king@canonical.com>

pages is being allocated however a null check on bv is being used
to see if the allocation failed. Fix this by checking if pages is
null.

Detected by CoverityScan, CID#1432974 ("Logically dead code")

Fixes: ccf7f4088af2dd ("CIFS: Add asynchronous context to support kernel AIO")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/cifs/misc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index b08531977daa..3b147dc6af63 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -810,7 +810,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
 
 	if (!pages) {
 		pages = vmalloc(max_pages * sizeof(struct page *));
-		if (!bv) {
+		if (!pages) {
 			kvfree(bv);
 			return -ENOMEM;
 		}
-- 
2.11.0

[toc] | [next] | [standalone]


#1643614

FromPavel Shilovsky <piastryyy@gmail.com>
Date2017-05-17 22:10 +0200
Message-ID<tIdqG-7Gg-33@gated-at.bofh.it>
In reply to#1643573
2017-05-17 11:24 GMT-07:00 Colin King <colin.king@canonical.com>:
> From: Colin Ian King <colin.king@canonical.com>
>
> pages is being allocated however a null check on bv is being used
> to see if the allocation failed. Fix this by checking if pages is
> null.
>
> Detected by CoverityScan, CID#1432974 ("Logically dead code")
>
> Fixes: ccf7f4088af2dd ("CIFS: Add asynchronous context to support kernel AIO")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/cifs/misc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
> index b08531977daa..3b147dc6af63 100644
> --- a/fs/cifs/misc.c
> +++ b/fs/cifs/misc.c
> @@ -810,7 +810,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
>
>         if (!pages) {
>                 pages = vmalloc(max_pages * sizeof(struct page *));
> -               if (!bv) {
> +               if (!pages) {
>                         kvfree(bv);
>                         return -ENOMEM;
>                 }
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Thanks for catching this!

Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>

--
Best regards,
Pavel Shilovsky

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web