LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH][next] ceph: Fix dereference of null pointer cf
@ 2021-08-29 18:18 Colin King
  2021-08-30 10:14 ` Ilya Dryomov
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2021-08-29 18:18 UTC (permalink / raw)
  To: Jeff Layton, Ilya Dryomov, Xiubo Li, ceph-devel
  Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

Currently in the case where kmem_cache_alloc fails the null pointer
cf is dereferenced when assigning cf->is_capsnap = false. Fix this
by adding a null pointer check and return path.

Addresses-Coverity: ("Dereference null return")
Fixes: b2f9fa1f3bd8 ("ceph: correctly handle releasing an embedded cap flush")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/ceph/caps.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 39db97f149b9..eceb3ceaac48 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -1746,6 +1746,8 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void)
 	struct ceph_cap_flush *cf;
 
 	cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL);
+	if (!cf)
+		return NULL;
 	cf->is_capsnap = false;
 	return cf;
 }
-- 
2.32.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH][next] ceph: Fix dereference of null pointer cf
  2021-08-29 18:18 [PATCH][next] ceph: Fix dereference of null pointer cf Colin King
@ 2021-08-30 10:14 ` Ilya Dryomov
  0 siblings, 0 replies; 2+ messages in thread
From: Ilya Dryomov @ 2021-08-30 10:14 UTC (permalink / raw)
  To: Colin King; +Cc: Jeff Layton, Xiubo Li, Ceph Development, kernel-janitors, LKML

On Sun, Aug 29, 2021 at 8:18 PM Colin King <colin.king@canonical.com> wrote:
>
> From: Colin Ian King <colin.king@canonical.com>
>
> Currently in the case where kmem_cache_alloc fails the null pointer
> cf is dereferenced when assigning cf->is_capsnap = false. Fix this
> by adding a null pointer check and return path.
>
> Addresses-Coverity: ("Dereference null return")
> Fixes: b2f9fa1f3bd8 ("ceph: correctly handle releasing an embedded cap flush")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  fs/ceph/caps.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
> index 39db97f149b9..eceb3ceaac48 100644
> --- a/fs/ceph/caps.c
> +++ b/fs/ceph/caps.c
> @@ -1746,6 +1746,8 @@ struct ceph_cap_flush *ceph_alloc_cap_flush(void)
>         struct ceph_cap_flush *cf;
>
>         cf = kmem_cache_alloc(ceph_cap_flush_cachep, GFP_KERNEL);
> +       if (!cf)
> +               return NULL;
>         cf->is_capsnap = false;
>         return cf;
>  }
> --
> 2.32.0
>

Hi Colin,

I guess we were too focused on the details of b2f9fa1f3bd8 to spot the
obvious...  It sat in next for a few days but apparently not enough to
be included in the Coverity run.  What is the frequency of these runs?

Applied and added an explicit stable tag since b2f9fa1f3bd8 is already
on its way to stable kernels.

Thanks,

                Ilya

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-08-30 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-29 18:18 [PATCH][next] ceph: Fix dereference of null pointer cf Colin King
2021-08-30 10:14 ` Ilya Dryomov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).