From: lixiaokeng Subject: [PATCH V2 04/14] multipathd: check MALLOC return value in mpath_pr_event_handler_fn Date: Tue, 8 Sep 2020 14:55:37 +0800 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com Content-Language: en-GB To: Christophe Varoqui , Martin Wilck , Benjamin Marzinski Cc: linfeilong , dm-devel mailing list , "liuzhiqiang (I)" List-Id: dm-devel.ids In mpath_pr_event_handler_fn, we use MALLOC instead of malloc, and check the return value of MALLOC. V1->V2: delete seting ret when jump to out Signed-off-by: Lixiaokeng Signed-off-by: Zhiqiang Liu Signed-off-by: Linfeilong --- multipathd/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multipathd/main.c b/multipathd/main.c index 67e9af11..f1264459 100644 --- a/multipathd/main.c +++ b/multipathd/main.c @@ -3365,7 +3365,6 @@ void * mpath_pr_event_handler_fn (void * pathp ) if (resp->prin_descriptor.prin_readkeys.additional_length == 0 ) { condlog(1, "%s: No key found. Device may not be registered.", pp->dev); - ret = MPATH_PR_SUCCESS; goto out; } condlog(2, "Multipath reservation_key: 0x%" PRIx64 " ", @@ -3387,12 +3386,13 @@ void * mpath_pr_event_handler_fn (void * pathp ) { condlog(0, "%s: Either device not registered or ", pp->dev); condlog(0, "host is not authorised for registration. Skip path"); - ret = MPATH_PR_OTHER; goto out; } - param= malloc(sizeof(struct prout_param_descriptor)); - memset(param, 0 , sizeof(struct prout_param_descriptor)); + param = (struct prout_param_descriptor *)MALLOC(sizeof(struct prout_param_descriptor)); + if (!param) + goto out; + param->sa_flags = mpp->sa_flags; memcpy(param->sa_key, &mpp->reservation_key, 8); param->num_transportid = 0; --