Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2233748ybi; Thu, 20 Jun 2019 11:18:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqzbqvZSsTXtX6QCuVj1zsd7Ww38FAXriwsijPtbdq6WU/W4fwImSM+SKmxIltNc/Pretp1L X-Received: by 2002:a17:90a:270f:: with SMTP id o15mr1024041pje.56.1561054738609; Thu, 20 Jun 2019 11:18:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561054738; cv=none; d=google.com; s=arc-20160816; b=ilMSwvro5SOmpQ9sPFnTxQDnJTBAYicsV+Dmgfk0F/y6+cAUzdeFjNK6vhy6yYcmdM 22T2CLSahddZ95Z5RU99wZvNzUnto6GX5n+splwZTNAGS61TLSYCa9RD2qglfs7FwAQG p/jHSqOEQTMu0OWbFsrQhPmBXXJ33W7FgU8HyYnDsr1764yrkUdHSLiC1ufzyCV6jY2Y 6ydONcfZrIigqltLmPvhY2FisaOQG3t1fPyN3wE+MsmXDUxH/34r2CPE0KGVuqzc/K1b kf10Z3IvyKJWZkln7ueuizfFDooZcAxFVEIkFFb1oGdnGji4p935nXPddM8oF1MgQJ1M VNtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kSSAao730Dg8v/qZERxEES6C5G/R6fQbhjPkz28stAA=; b=MNxTSkVvsVs5Y+yfnhT+pZ4DojSWaFJew3uQayLB/9nBcq+x5o6rgsQ6pzZErEqGEj LarxXF6+zUrhiexYJKrgdQar06PBVmmkeFSbeX+wG4zeIMvDKo21UOO7UlFvFNSZCAie LSO6ULoFMYyUxyHt93ZpPbofQit5qIT1mVX0UTK5o5O3i/U5x+51ZUqzJHtv6p1w4XJw uo27jWNXlWxA/twr+IufCjgfY3q851A5qWKQkROlklhybfjNUsCsaAweYUmRE6RJ3s0j 4iD8wQHzfPDD6rVTofcaNMQz+iDBQE9alp6cYCPCUTVlPFHyIiCyQXrKNC0bANTCX/uU prnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="bSYHoC/q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s36si342019pld.164.2019.06.20.11.18.43; Thu, 20 Jun 2019 11:18:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="bSYHoC/q"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729807AbfFTSRy (ORCPT + 99 others); Thu, 20 Jun 2019 14:17:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:46878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729751AbfFTSRd (ORCPT ); Thu, 20 Jun 2019 14:17:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 53ED4205F4; Thu, 20 Jun 2019 18:17:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1561054652; bh=FNNY4z0fWNTg2RzTbJOuQrUVa1cKqXAWH9utYhcXyvA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bSYHoC/q6nFEHtWW7Q31I2Mz0P8B7/w7mhFzOCUTLjgutbfbPlVzcu0lmP9DW3LCt vGVJSU6QAUa8Uf9y6L8zx8JNt75azVQnXgfpD/L7VPiXmuJ/HFETrY/16pHeYecWZ+ WHEprz3RMoEM0k7958cC7dZ3PP7uqNmstKdZE3Y0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jes Sorensen , Jens Axboe , Sasha Levin Subject: [PATCH 5.1 83/98] blk-mq: Fix memory leak in error handling Date: Thu, 20 Jun 2019 19:57:50 +0200 Message-Id: <20190620174353.494201302@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190620174349.443386789@linuxfoundation.org> References: <20190620174349.443386789@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 41de54c64811bf087c8464fdeb43c6ad8be2686b ] If blk_mq_init_allocated_queue() fails, make sure to free the poll stat callback struct allocated. Signed-off-by: Jes Sorensen Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-mq.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 11efca3534ad..00b826399228 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2846,7 +2846,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, goto err_exit; if (blk_mq_alloc_ctxs(q)) - goto err_exit; + goto err_poll; /* init q->mq_kobj and sw queues' kobjects */ blk_mq_sysfs_init(q); @@ -2907,6 +2907,9 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, kfree(q->queue_hw_ctx); err_sys_init: blk_mq_sysfs_deinit(q); +err_poll: + blk_stat_free_callback(q->poll_cb); + q->poll_cb = NULL; err_exit: q->mq_ops = NULL; return ERR_PTR(-ENOMEM); -- 2.20.1