Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6022609ybc; Wed, 27 Nov 2019 13:33:55 -0800 (PST) X-Google-Smtp-Source: APXvYqzpHUJTIRPUUJY/kXqkuU0UbHNctyTp3FshHEReB1XeDvk73u2yFBXuaXevxNrUFL/1kGSV X-Received: by 2002:a17:906:6847:: with SMTP id a7mr25455353ejs.95.1574890435013; Wed, 27 Nov 2019 13:33:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574890435; cv=none; d=google.com; s=arc-20160816; b=sf0WrPMh6Pne5XL87QHaFdAyVhOp9zHJ4FX/szhyt+AorHROWvOoJQmTtQ4GDgoTD5 aMmZegtvw0DuIbxqPFxAAmnW5hHDKTw6QWz6c/9iCn/kJJH/236YRrZGKxknj+FKxrPI 7+XLcXZnrg+FapqDj+/MsDL6M5XAyEFBOY1F6nvVI1gVY9oNAqQyL4ItnH8dOL9RYdyu NL602t/6R78BupndcS1S/T7CMXZNlWpcQX8b+N5s0+p5Z8tmgn3AtV0qrJvLX1GiQLet 3pce6XoDdtpCDxrqwaD8CL++oaWv2J1I8+/EiFNHIc4PoRxJYtP1w0NZKT4n5k9QKTF+ jCKA== 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=STnIIlto4G0onDAxc5WfZng8iMSXgnzwFmJ+etHAe38=; b=C2uxVuNg6PziqOphhoovjrLYaXwkZbaK3nM9vS/jf6PxMWkhrnOf1bmcBMI+AABgZa BN+Nq80YBtJw3/HlOINtIgzIjTZJNtJm2ojLSs7zMAPLQqH3g50k9DiE8PWExYUEahlG 3GrR3GnwEZzyjxgcHFPgnlAHZcHfm369UTqqheQdPVkwKi5gKWxMhwZaDnf0r7RN3/kz g1aGU3BhbyPrdyYqOCpuUzQ+Q+Trfo/lNPBxOOk9bfoeW3tMiqMmy65YYEZalNPUsO2B 3zxXXX5LywgCrhMG80mZP3yFAXwIF5p4U/aDJZjADgQqamaTGLNd7F+j7j0WV23D7IRD OWtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=LJgBCY77; 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 m17si3636610edv.108.2019.11.27.13.33.31; Wed, 27 Nov 2019 13:33:55 -0800 (PST) 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=LJgBCY77; 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 S1731175AbfK0U5W (ORCPT + 99 others); Wed, 27 Nov 2019 15:57:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:48256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731165AbfK0U5Q (ORCPT ); Wed, 27 Nov 2019 15:57:16 -0500 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 265102084D; Wed, 27 Nov 2019 20:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888235; bh=2tfT+JNrdVWZ+oMRcmgZUtHbBrEltXM0CPEOcEo0S8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LJgBCY77HGP9bXTN45g+s93V4pMECjuF0jogJF371dcLcHlv2TUL0EuHSww6uB6lO UG9VX4EASi7pkixuUKPtDCBmFFbKCqMPBdYETWVqVO1Q26IL2xQZ3JiUC7gtIRSvjI 6cpT4IUS+sq71WN+yXzmpQld120XIpJlwQy09W2o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Josef Bacik , Mike Christie , Sun Ke , Jens Axboe Subject: [PATCH 4.19 014/306] nbd:fix memory leak in nbd_get_socket() Date: Wed, 27 Nov 2019 21:27:44 +0100 Message-Id: <20191127203115.750394671@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@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 From: Sun Ke commit dff10bbea4be47bdb615b036c834a275b7c68133 upstream. Before returning NULL, put the sock first. Cc: stable@vger.kernel.org Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup") Reviewed-by: Josef Bacik Reviewed-by: Mike Christie Signed-off-by: Sun Ke Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/block/nbd.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -945,6 +945,7 @@ static struct socket *nbd_get_socket(str if (sock->ops->shutdown == sock_no_shutdown) { dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown callout must be supported.\n"); *err = -EINVAL; + sockfd_put(sock); return NULL; }