All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
To: Martin Wilck <mwilck@suse.com>,
	bmarzins@redhat.com,
	Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Zdenek Kabelac <zkabelac@redhat.com>
Cc: linfeilong <linfeilong@huawei.com>,
	Yanxiaodan <yanxiaodan@huawei.com>,
	dm-devel@redhat.com, lixiaokeng <lixiaokeng@huawei.com>
Subject: Re: [PATCH 6/6] multipathd: return NULL if MALLOC fails in alloc_waiteri, func
Date: Mon, 17 Aug 2020 22:42:49 +0800	[thread overview]
Message-ID: <e80c36ed-6034-1a4e-59f0-4de34965e55a@huawei.com> (raw)
In-Reply-To: <d1268e158e8c063c12e7f5ab1e8a72109c4a336a.camel@suse.com>



On 2020/8/17 17:21, Martin Wilck wrote:
> On Sun, 2020-08-16 at 09:46 +0800, Zhiqiang Liu wrote:
>> In alloc_waiter func, if MALLOC fails, wp is equal to NULL.
>> If now we call memset(wp), segmentation fault will occur.
>>
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
>> ---
>>  multipathd/waiter.c | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/multipathd/waiter.c b/multipathd/waiter.c
>> index e645766..80e6e6e 100644
>> --- a/multipathd/waiter.c
>> +++ b/multipathd/waiter.c
>> @@ -33,8 +33,10 @@ static struct event_thread *alloc_waiter (void)
>>  	struct event_thread *wp;
>>
>>  	wp = (struct event_thread *)MALLOC(sizeof(struct
>> event_thread));
>> -	memset(wp, 0, sizeof(struct event_thread));
>> +	if (!wp)
>> +		return NULL;
>>
>> +	memset(wp, 0, sizeof(struct event_thread));
>>  	return wp;
>>  }
>>
> 
> This is correct, but while you're at it, please also remove the
> superfluous memset() call (counterintuitively, MALLOC(x) maps to
> calloc(1, x)).
> 
> Martin
> 
Thanks for your suggestion.
I will remove the memset() call in v2 patch.

Zhiqiang
> 
> 
> .
> 

      reply	other threads:[~2020-08-17 14:42 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-16  1:41 [PATCH 0/6] multipath-tools series: some cleanups and fixes Zhiqiang Liu
2020-08-16  1:42 ` [PATCH 1/6] checker: remove useless name check in checker_get func Zhiqiang Liu
2020-08-17  8:05   ` Martin Wilck
2020-08-17 15:12     ` Zhiqiang Liu
2020-08-17 15:25       ` Martin Wilck
2020-08-17 15:49         ` Zhiqiang Liu
2020-08-16  1:42 ` [PATCH 2/6] multipathd: adopt static char* arr in daemon_status Zhiqiang Liu
2020-08-17  8:23   ` Martin Wilck
2020-08-17 15:15     ` Zhiqiang Liu
2020-08-16  1:44 ` [PATCH 3/6] multipathd: adopt static char* arr in sd_notify_status func Zhiqiang Liu
2020-08-17  8:35   ` Martin Wilck
2020-08-17 15:33     ` Zhiqiang Liu
2020-08-17 15:44       ` Martin Wilck
2020-08-17 15:51         ` Zhiqiang Liu
2020-08-17 15:59         ` Zhiqiang Liu
2020-08-16  1:45 ` [PATCH 4/6] libmultipath: check blist before calling MALLOC in alloc_ble_device func Zhiqiang Liu
2020-08-17  8:51   ` Martin Wilck
2020-08-18  6:51     ` Benjamin Marzinski
2020-08-16  1:45 ` [PATCH 5/6] vector: add lower boundary check in vector_foreach_slot_after Zhiqiang Liu
2020-08-17  9:11   ` Martin Wilck
2020-08-17 15:58     ` Zhiqiang Liu
2020-08-16  1:46 ` [PATCH 6/6] multipathd: return NULL if MALLOC fails in alloc_waiteri, func Zhiqiang Liu
2020-08-17  9:21   ` Martin Wilck
2020-08-17 14:42     ` Zhiqiang Liu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e80c36ed-6034-1a4e-59f0-4de34965e55a@huawei.com \
    --to=liuzhiqiang26@huawei.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=linfeilong@huawei.com \
    --cc=lixiaokeng@huawei.com \
    --cc=mwilck@suse.com \
    --cc=yanxiaodan@huawei.com \
    --cc=zkabelac@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.