From: Martin Wilck Subject: Re: [PATCH 04/14] multipathd: check MALLOC return value in, mpath_pr_event_handler_fn Date: Thu, 03 Sep 2020 20:57:55 +0200 Message-ID: <41d51bddd2de5bf18d50bd39cf356ee769074647.camel@suse.com> References: <37544d4c-950f-4281-3b66-e4d1884c5167@huawei.com> <8b45a04b-c851-94ba-fcba-676c03b060e7@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <8b45a04b-c851-94ba-fcba-676c03b060e7@huawei.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com To: lixiaokeng , Benjamin Marzinski , Christophe Varoqui , dm-devel mailing list Cc: linfeilong , "liuzhiqiang (I)" List-Id: dm-devel.ids On Wed, 2020-09-02 at 15:17 +0800, lixiaokeng wrote: > In mpath_pr_event_handler_fn, we use MALLOC instead of malloc, and > check > the return value of MALLOC. > > Signed-off-by: Lixiaokeng > Signed-off-by: Zhiqiang Liu > Signed-off-by: Linfeilong > --- > multipathd/main.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/multipathd/main.c b/multipathd/main.c > index 67e9af11..7180d3c1 100644 > --- a/multipathd/main.c > +++ b/multipathd/main.c > @@ -3391,8 +3391,12 @@ void * mpath_pr_event_handler_fn (void * > pathp ) > 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) { > + ret = MPATH_PR_OTHER; > + goto out; > + } No need to set the local variable "ret" when you jump to "out". I can see this is done elsewhere in this function, too. It has been like that since day 1. Regards, Martin