diff mbox series

libceph: Avoid a NULL pointer dereference

Message ID 20190314211724.21306-1-pakki001@umn.edu
State Awaiting Upstream
Delegated to: David Miller
Headers show
Series libceph: Avoid a NULL pointer dereference | expand

Commit Message

Aditya Pakki March 14, 2019, 9:17 p.m. UTC
kmalloc allocates memory for dest->name and attempts to call
memcpy without a check for failure. This patch avoids such a scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 net/ceph/osdmap.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Luis Henriques March 15, 2019, 11:24 a.m. UTC | #1
Aditya Pakki <pakki001@umn.edu> writes:

> kmalloc allocates memory for dest->name and attempts to call
> memcpy without a check for failure. This patch avoids such a scenario.

Since kmalloc is being invoked with the __GFP_NOFAIL flag, it will never
fail.  Thus, there's no point in checking for NULL in this case.

Cheers,
diff mbox series

Patch

diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 48a31dc9161c..c76a7c7e6a77 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1901,6 +1901,8 @@  void ceph_oid_copy(struct ceph_object_id *dest,
 	} else {
 		dest->name = dest->inline_name;
 	}
+	if (!dest->name)
+		return;
 	memcpy(dest->name, src->name, src->name_len + 1);
 	dest->name_len = src->name_len;
 }