libceph: allow ceph_buffer_put() to receive a NULL ceph_buffer [Linux 4.14.143]

This Linux kernel change "libceph: allow ceph_buffer_put() to receive a NULL ceph_buffer" is included in the Linux 4.14.143 release. This change is authored by Luis Henriques <lhenriques [at]> on Fri Jul 19 15:32:19 2019 +0100. The commit for this change in Linux stable tree is 2aeaba9 (patch) which is from upstream commit 5c49895. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 5c49895.

libceph: allow ceph_buffer_put() to receive a NULL ceph_buffer

[ Upstream commit 5c498950f730aa17c5f8a2cdcb903524e4002ed2 ]

Signed-off-by: Luis Henriques <>
Reviewed-by: Jeff Layton <>
Signed-off-by: Ilya Dryomov <>
Signed-off-by: Sasha Levin <>

There are 3 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 include/linux/ceph/buffer.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/ceph/buffer.h b/include/linux/ceph/buffer.h
index 5e58bb2..11cdc7c 100644
--- a/include/linux/ceph/buffer.h
+++ b/include/linux/ceph/buffer.h
@@ -30,7 +30,8 @@ static inline struct ceph_buffer *ceph_buffer_get(struct ceph_buffer *b)

 static inline void ceph_buffer_put(struct ceph_buffer *b)
-   kref_put(&b->kref, ceph_buffer_release);
+   if (b)
+       kref_put(&b->kref, ceph_buffer_release);

 extern int ceph_decode_buffer(struct ceph_buffer **b, void **p, void *end);

Leave a Reply

Your email address will not be published. Required fields are marked *