From 307528ef9a33a4d294b3ea49bbf5f0b16b27aa0f Mon Sep 17 00:00:00 2001 From: "Anand V. Avati" Date: Sat, 18 Apr 2009 01:09:31 +0530 Subject: disconnect transport peer if system is out of memory while allocating iobuf --- transport/ib-verbs/src/ib-verbs.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'transport/ib-verbs') diff --git a/transport/ib-verbs/src/ib-verbs.c b/transport/ib-verbs/src/ib-verbs.c index 5933e50fa..dc5ae1137 100644 --- a/transport/ib-verbs/src/ib-verbs.c +++ b/transport/ib-verbs/src/ib-verbs.c @@ -525,6 +525,13 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p, if (size1) { hdr = CALLOC (1, size1); + if (!hdr) { + gf_log (this->xl->name, GF_LOG_ERROR, + "unable to allocate header for peer %s", + this->peerinfo.identifier); + ret = -ENOMEM; + goto err; + } memcpy (hdr, copy_from, size1); copy_from += size1; *hdr_p = hdr; @@ -533,6 +540,13 @@ ib_verbs_receive (transport_t *this, char **hdr_p, size_t *hdrlen_p, if (size2) { iobuf = iobuf_get (this->xl->ctx->iobuf_pool); + if (!iobuf) { + gf_log (this->xl->name, GF_LOG_ERROR, + "unable to allocate IO buffer for peer %s", + this->peerinfo.identifier); + ret = -ENOMEM; + goto err; + } memcpy (iobuf->ptr, copy_from, size2); *iobuf_p = iobuf; } -- cgit