Blob Blame History Raw
From f6b4b4308b838b29f17b2a4a54385269991f0118 Mon Sep 17 00:00:00 2001
From: Mohit Agrawal <moagrawal@redhat.com>
Date: Thu, 5 Jul 2018 15:02:06 +0530
Subject: [PATCH 315/325] changelog: fix br-state-check.t crash for brick_mux

Problem: br-state-check.t is getting crash

Solution: Check condition in rpcsvc_request_create
          before allocate memory from rxpool

> BUG: 1597776
> Change-Id: I4fde1ade6073f603c32453f1840395db9a9155b7
> fixes: bz#1597776
> (cherry picked from commit e31c7a7c0c1ea3f6e931935226fb976a92779ba7)
> (Reviewed on upstream link https://review.gluster.org/#/c/20132/)

BUG: 1597768
Change-Id: I3a0dc8f9625a6ab9ce8364119413ae45e321e620
Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/143719
Tested-by: RHGS Build Bot <nigelb@redhat.com>
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
---
 rpc/rpc-lib/src/rpcsvc.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/rpc/rpc-lib/src/rpcsvc.c b/rpc/rpc-lib/src/rpcsvc.c
index 3acaa8b..8d0c409 100644
--- a/rpc/rpc-lib/src/rpcsvc.c
+++ b/rpc/rpc-lib/src/rpcsvc.c
@@ -447,7 +447,7 @@ rpcsvc_request_create (rpcsvc_t *svc, rpc_transport_t *trans,
         size_t                  msglen  = 0;
         int                     ret     = -1;
 
-        if (!svc || !trans)
+        if (!svc || !trans || !svc->rxpool)
                 return NULL;
 
         /* We need to allocate the request before actually calling
@@ -1473,6 +1473,7 @@ rpcsvc_get_listener (rpcsvc_t *svc, uint16_t port, rpc_transport_t *trans)
 {
         rpcsvc_listener_t  *listener      = NULL;
         char                found         = 0;
+        rpcsvc_listener_t  *next          = NULL;
         uint32_t            listener_port = 0;
 
         if (!svc) {
@@ -1481,7 +1482,7 @@ rpcsvc_get_listener (rpcsvc_t *svc, uint16_t port, rpc_transport_t *trans)
 
         pthread_mutex_lock (&svc->rpclock);
         {
-                list_for_each_entry (listener, &svc->listeners, list) {
+                list_for_each_entry_safe (listener, next, &svc->listeners, list) {
                         if (listener && trans) {
                                 if (listener->trans == trans) {
                                         found = 1;
-- 
1.8.3.1