Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3333213pxj; Mon, 24 May 2021 04:26:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyziNIH3qe3/BCnShUNiEPUFla+/ZNZPz8PlEoD9Xv/MXPaD944bSnYZifE+9MKYbaU13TZ X-Received: by 2002:a05:6402:3098:: with SMTP id de24mr24728310edb.339.1621855574225; Mon, 24 May 2021 04:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621855574; cv=none; d=google.com; s=arc-20160816; b=ZMfTvHa6KZ/K1lFRlRkocgglQvk9HdmAeKns0Bj9Ki8sP+zoyRcCzlwI4aHpoKbric QawLqqSBMQTu6BSpwoDRFw+DinvZ1oAYiF8cVOipI//wQfRnIoj3pv93e999rB41gEXG scXq87mrSFMkaukRhsIMun4fdIOB/7Cz4rcYs+XGvSu1ju+z2//MfPrqhBxqRLQd/whL gCaqWGSlFMYq/hMDJ2GS7PNUii4ymMXrAM65bXDYAf3svaT/1QDIPExz6VLmxcWrxYac HxWPpS3CeNEnll1FxEFhZNqamQotX9wPxfCskOyqCg53n0c0n5ErXzV28sO5IEHOiMqC 6vIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=lISgFRAVaxVZDmucz3yNu3OzDiv5AD40fI8+uuP3+jY=; b=NVQAo5Qm3/9e3WD3D+SyFFfEs90r6oirc4O9DsxgGZCb8xVDdyqOlu+a4ay18uyOtR 0DsZa/g6Ta6dN+3idQAgiUoR0ylEmuCRNvSxV/xZqnCloJLDocTyumSTi5HiV5j08SBi FIFiV7EC9Q4P8QehqPwkUjDGCY3LGa4k9b2gX86y41LwxnSC0gVLVNHOR8EUdTZBz/iG QF689LIjP/RYTC47IImPtNDNO5seCh1qbPMBHJt5S/6vTjr3F/mFpuwMh52WMZL0Hy// 1grUlgVDKXZfDnV9a7bJ0yPKkyVNhAMcHB8dv6iaL6W9s9oH/Mno9KeUdSFxz22gSY61 QnGA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq5si8297301ejb.736.2021.05.24.04.25.51; Mon, 24 May 2021 04:26:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232596AbhEXL0x (ORCPT + 99 others); Mon, 24 May 2021 07:26:53 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:5677 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232726AbhEXL0X (ORCPT ); Mon, 24 May 2021 07:26:23 -0400 Received: from dggems702-chm.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4FpZYS1wyGz1BQwD for ; Mon, 24 May 2021 19:22:04 +0800 (CST) Received: from dggpemm500014.china.huawei.com (7.185.36.153) by dggems702-chm.china.huawei.com (10.3.19.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:24:54 +0800 Received: from [10.174.179.184] (10.174.179.184) by dggpemm500014.china.huawei.com (7.185.36.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Mon, 24 May 2021 19:24:54 +0800 Subject: [PATCH 09/12] lib/ss/error.c: check return value malloc in ss_name() From: Wu Guanghao To: CC: , References: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Message-ID: Date: Mon, 24 May 2021 19:24:53 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.2.1 MIME-Version: 1.0 In-Reply-To: <266bc52e-e279-ce84-0e1f-1405b9bc6174@huawei.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.179.184] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500014.china.huawei.com (7.185.36.153) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org In ss_name(), we should check return value of malloc(), otherwise, it may cause a segmentation fault problem. Signed-off-by: Zhiqiang Liu Signed-off-by: Wu Guanghao --- lib/ss/error.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ss/error.c b/lib/ss/error.c index 8d345a9f..656b71be 100644 --- a/lib/ss/error.c +++ b/lib/ss/error.c @@ -42,6 +42,8 @@ char *ss_name(int sci_idx) (strlen(infop->subsystem_name)+ strlen(infop->current_request)+ 4)); + if (ret_val == (char *)NULL) + return ((char *)NULL); cp = ret_val; cp1 = infop->subsystem_name; while (*cp1) --