From patchwork Thu Nov 3 01:16:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Liao, Chang" X-Patchwork-Id: 13029379 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 96391C4332F for ; Thu, 3 Nov 2022 01:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=5Eiamae8cD3n5WAZci2pOxNF8QSpXtqvp1y6yU5HtQU=; b=r2XEgGj42Z/A2B BsoBiWqSVs8qjLOO5mEFK3oBxlBJPNYUkpYxKx5QeMwoLX1VFYA2FU1+xFA5tqZfRi1D+mCHrod26 2zKvhLJ8UJ1rqvGqXRZI2CNniiYEq4Dmo3zzxdZqdGmtJMaARTi2ptPz3RkpDyXOYPiRDBhz7ZTLK 7lT+yNsCb+/q7Yox2lkQsfgmYVL3RTo5QQeLQTYmMnhKNOoHW9WiOsa/HQ9ZaKhxXaslrp0VSSeQH Ie9SVh7Jlw2cSj7E12NVVxn53B6M8GXZlhriYAiSIiBAo7IbSHdnNZS3K1LtJlNgBEkKBSqg7M8JW YB8NoTp17/vvDnlygU7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqOu3-00FVDp-Up; Thu, 03 Nov 2022 01:20:20 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqOu0-00FVA6-La for linux-arm-kernel@lists.infradead.org; Thu, 03 Nov 2022 01:20:18 +0000 Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N2mBz6kbGzbcDF; Thu, 3 Nov 2022 09:19:55 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 09:20:00 +0800 From: Liao Chang To: , , , CC: , Subject: [PATCH 1/2] ARM: kprobes: Improve robustness for kprobe coverage testing Date: Thu, 3 Nov 2022 09:16:45 +0800 Message-ID: <20221103011645.138749-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221102_182016_917894_DC4D9077 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Improve robustness for kprobe coverage testing, avoid to access NULL pointer in coverage_start_fn. Fixes: 963780dfe390 ("ARM: kprobes: Add decoding table test coverage analysis") Signed-off-by: Liao Chang --- arch/arm/probes/kprobes/test-core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c index c562832b8627..e6a932e863bb 100644 --- a/arch/arm/probes/kprobes/test-core.c +++ b/arch/arm/probes/kprobes/test-core.c @@ -766,6 +766,11 @@ static int coverage_start(const union decode_item *table) coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES, sizeof(struct coverage_entry), GFP_KERNEL); + if (!coverage.base) { + pr_err("FAIL: Out of space for allocating coverage entries"); + return -ENOMEM; + } + coverage.num_entries = 0; coverage.nesting = 0; return table_iter(table, coverage_start_fn, &coverage);