From patchwork Sat Apr 18 05:20:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tiezhu Yang X-Patchwork-Id: 11496291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7C7F7174A for ; Sat, 18 Apr 2020 05:20:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 659BD22242 for ; Sat, 18 Apr 2020 05:20:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725983AbgDRFUT (ORCPT ); Sat, 18 Apr 2020 01:20:19 -0400 Received: from mail.loongson.cn ([114.242.206.163]:34254 "EHLO loongson.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725849AbgDRFUS (ORCPT ); Sat, 18 Apr 2020 01:20:18 -0400 Received: from linux.localdomain (unknown [113.200.148.30]) by mail.loongson.cn (Coremail) with SMTP id AQAAf9Dxj9wAjppe2UQpAA--.8S5; Sat, 18 Apr 2020 13:20:03 +0800 (CST) From: Tiezhu Yang To: Luis Chamberlain , Shuah Khan Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: [PATCH 4/4] test_kmod: Avoid potential double free in trigger_config_run_type() Date: Sat, 18 Apr 2020 13:20:00 +0800 Message-Id: <1587187200-13109-4-git-send-email-yangtiezhu@loongson.cn> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1587187200-13109-1-git-send-email-yangtiezhu@loongson.cn> References: <1587187200-13109-1-git-send-email-yangtiezhu@loongson.cn> X-CM-TRANSID: AQAAf9Dxj9wAjppe2UQpAA--.8S5 X-Coremail-Antispam: 1UD129KBjvdXoWrtF4ruw4xuryxZw1fXw4Utwb_yoWxKwc_Ca 47Jr1DWr1UJrZ8uw13Z395ZF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sender: linux-kselftest-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org It should set config->test_fs instead of config->test_driver as NULL after kfree_const(config->test_fs) to avoid potential double free. Signed-off-by: Tiezhu Yang Acked-by: Luis Chamberlain --- lib/test_kmod.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_kmod.c b/lib/test_kmod.c index e651c37..eab5277 100644 --- a/lib/test_kmod.c +++ b/lib/test_kmod.c @@ -745,7 +745,7 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev, break; case TEST_KMOD_FS_TYPE: kfree_const(config->test_fs); - config->test_driver = NULL; + config->test_fs = NULL; copied = config_copy_test_fs(config, test_str, strlen(test_str)); break;