socket: Add NULL check for failed ioq entry allocation

This is seen in OOM situations.

Signed-off-by: Shehjar Tikoo <shehjart@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>

BUG: 679 (Crash in socket_ioq_new)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=679
This commit is contained in:
Shehjar Tikoo 2010-02-25 15:38:11 +00:00 committed by Anand V. Avati
parent bcab556247
commit 2c7e6f22f7

View File

@ -299,6 +299,8 @@ __socket_ioq_new (transport_t *this, char *buf, int len,
/* TODO: use mem-pool */
entry = CALLOC (1, sizeof (*entry));
if (!entry)
return NULL;
assert (count <= (MAX_IOVEC-2));
@ -1319,6 +1321,8 @@ socket_submit (transport_t *this, char *buf, int len,
priv->submit_log = 0;
entry = __socket_ioq_new (this, buf, len, vector, count, iobref);
if (!entry)
goto unlock;
if (list_empty (&priv->ioq)) {
ret = __socket_ioq_churn_entry (this, entry);