[dm-devel] [PATCH V3 06/14] kpartx: check return value of malloc in main func

Martin Wilck mwilck at suse.com
Tue Sep 8 14:25:11 UTC 2020


On Tue, 2020-09-08 at 16:49 +0800, lixiaokeng wrote:
> In main func of kpartx.c, we should check return value of
> malloc before using it.
> 
> V1->V2: change malloc to xmalloc
> 
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26 at huawei.com>
> Signed-off-by: Lixiaokeng <lixiaokeng at huawei.com>
> ---
>  kpartx/kpartx.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/kpartx/kpartx.c b/kpartx/kpartx.c
> index 98f6176e..6de3c9c4 100644
> --- a/kpartx/kpartx.c
> +++ b/kpartx/kpartx.c
> @@ -61,6 +61,9 @@ struct pt {
>  int ptct = 0;
>  int udev_sync = 1;
> 
> +extern void *
> +xmalloc (size_t size);
> +

Please don't use "extern". It's misleading, because this function is
defined in the same file. You should actually change xmalloc() to a
static function.

Regards,
Martin





More information about the dm-devel mailing list