Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp332841pxb; Thu, 9 Sep 2021 01:54:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFZuscGBjsjB3ZkE95sIjQQiEsLrb7076NcN1Nszq+V5LxU4PwDfHJrl8SrlNuwUV4f5iP X-Received: by 2002:a6b:2bce:: with SMTP id r197mr1744021ior.212.1631177661877; Thu, 09 Sep 2021 01:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631177661; cv=none; d=google.com; s=arc-20160816; b=ZhCMumcRFTX2EOkaeyVnc8Gn2xdyGY1KXFahig62Xv50jWSHgxu3U+mACrjY/fDEUa gx2GzrUTgZI8AFOtNY6vkrY7R7wGdaLl7kP7Rgl2OuR5TTYNE3ecCZ28xYyVj42PDQxR B9JKvV6ZfYd1FChYcBDxEHWix/wawQDC+2yqxlv8RxznHntSjqkPmdEh22eZykEvA13D oBSaXiAVwVJdFE6eAatTHC/7oohwQKcNZtNP8s0OmFptf84aWiPonUqgwMvtgSFGCXQW oWEZptReZ3Fml69GnTFiN3mlPdYLcHJHmJ79f31C2rp/T10Fx7GqFJ91AulzuBsSN6CI 5QZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Vbxu4E50PhmxgPDmolkjW/M8m1rpKhp3WNuzEsng8EE=; b=xjNHEh/9ywFqQyWB1Ap5evpOR3tx+1oEeTSO/RIeV+1pEnB0zaA5TQ+OVz0N/E7B5b nU3DGt2eWfgPl0Wk+efb4ic+3yOeFq42U6idTW89WTIhbdvArwWDhYYfXhOm8khsd19W zkCZiBWonpE00x1VlsvvH7fg6tyYlpeos/7MAzHa6ni2BU+iNv1NB2cc+hbB0nGvYB+8 iARgylfhuWFJbOL7pgB6OX6/lWpxrbEIHBWRJn8xrC8luYmf019l3eDZEYcjUDqiJZBc NcsLZ5HEIZJn3NzpwPhKuMCoerhGPKO8pEcNTfWxX0W84Y7ao1BkQBYXGzNG4fG4S2/P 0NOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 y28si1146967iot.48.2021.09.09.01.54.10; Thu, 09 Sep 2021 01:54:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S231825AbhIIIyY (ORCPT + 99 others); Thu, 9 Sep 2021 04:54:24 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:9021 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbhIIIyX (ORCPT ); Thu, 9 Sep 2021 04:54:23 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4H4t6q5gPkzVqZv; Thu, 9 Sep 2021 16:52:19 +0800 (CST) Received: from dggpemm500004.china.huawei.com (7.185.36.219) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 9 Sep 2021 16:53:12 +0800 Received: from huawei.com (10.174.28.241) by dggpemm500004.china.huawei.com (7.185.36.219) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.8; Thu, 9 Sep 2021 16:53:12 +0800 From: Bixuan Cui To: , CC: , , Subject: [PATCH -next] io-wq: Fix memory leak in create_io_worker Date: Thu, 9 Sep 2021 16:49:19 +0800 Message-ID: <20210909084919.29644-1-cuibixuan@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.174.28.241] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm500004.china.huawei.com (7.185.36.219) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If io_should_retry_thread is false, free the worker before goto fails. Fixes: 3146cba99aa2 ("io-wq: make worker creation resilient against signals") Reported-by: syzbot+65454c239241d3d647da@syzkaller.appspotmail.com Signed-off-by: Bixuan Cui --- fs/io-wq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/io-wq.c b/fs/io-wq.c index d80e4a735677..036953f334d4 100644 --- a/fs/io-wq.c +++ b/fs/io-wq.c @@ -759,6 +759,7 @@ static bool create_io_worker(struct io_wq *wq, struct io_wqe *wqe, int index) if (!IS_ERR(tsk)) { io_init_new_worker(wqe, worker, tsk); } else if (!io_should_retry_thread(PTR_ERR(tsk))) { + kfree(worker); goto fail; } else { INIT_WORK(&worker->work, io_workqueue_create); -- 2.17.1