From: "Theodore Ts'o" <tytso@mit.edu>
To: wuguanghao <wuguanghao3@huawei.com>
Cc: linux-ext4@vger.kernel.org, linfeilong@huawei.com,
liuzhiqiang26@huawei.com
Subject: Re: [PATCH v3 10/12] hashmap: change return value type of ext2fs_hashmap_add()
Date: Mon, 2 Aug 2021 22:33:52 -0400 [thread overview]
Message-ID: <YQirECZyPrR791AS@mit.edu> (raw)
In-Reply-To: <20210728015648.284588-4-wuguanghao3@huawei.com>
On Wed, Jul 28, 2021 at 09:56:47AM +0800, wuguanghao wrote:
> From: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>
> In ext2fs_hashmap_add(), new entry is allocated by calling
> malloc(). If malloc() return NULL, it will cause a
> segmentation fault problem.
>
> Here, we change return value type of ext2fs_hashmap_add()
> from void to int. If allocating new entry fails, we will
> return 1, and the callers should also verify the return
> value of ext2fs_hashmap_add().
>
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: Wu Guanghao <wuguanghao3@huawei.com>
Thanks, applied.
Note: I changed ext2fs_hashmap_add() to return an int instead of an
errocode_t. The commit description said it was going to be an int,
and the code returns -1 (so I fixed the commit description to reflect
-1). Note that errcode_t is not appropriate for non-errno / com_err
error codes. So making the function prototype of hashmap_add() to
return an int is the correct thing to do.
Cheers,
- Ted
next prev parent reply other threads:[~2021-08-03 2:34 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-28 1:56 [PATCH v3 00/12] e2fsprogs: some bugfixs wuguanghao
2021-07-28 1:56 ` [PATCH v3 04/12] ss_add_info_dir: don't zap the info->info_dirs and check whether wuguanghao
2021-08-03 2:00 ` Theodore Ts'o
2021-07-28 1:56 ` [PATCH v3 05/12] ss_create_invocation: fix memory leak and check whether NULL pointer wuguanghao
2021-08-03 2:01 ` Theodore Ts'o
2021-07-28 1:56 ` [PATCH v3 10/12] hashmap: change return value type of ext2fs_hashmap_add() wuguanghao
2021-08-03 2:33 ` Theodore Ts'o [this message]
2021-07-28 1:56 ` [PATCH v3 11/12] misc/lsattr: check whether path is NULL in lsattr_dir_proc() wuguanghao
2021-08-03 2:35 ` Theodore Ts'o
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=YQirECZyPrR791AS@mit.edu \
--to=tytso@mit.edu \
--cc=linfeilong@huawei.com \
--cc=linux-ext4@vger.kernel.org \
--cc=liuzhiqiang26@huawei.com \
--cc=wuguanghao3@huawei.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.