From patchwork Wed Mar 1 16:47:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josef Bacik X-Patchwork-Id: 9598869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 96D3C60574 for ; Wed, 1 Mar 2017 17:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8ECEA284EE for ; Wed, 1 Mar 2017 17:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 83796284F7; Wed, 1 Mar 2017 17:50:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A5DE7283E0 for ; Wed, 1 Mar 2017 17:50:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752928AbdCARu0 (ORCPT ); Wed, 1 Mar 2017 12:50:26 -0500 Received: from mx0b-00082601.pphosted.com ([67.231.153.30]:42167 "EHLO mx0b-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751592AbdCARuA (ORCPT ); Wed, 1 Mar 2017 12:50:00 -0500 Received: from pps.filterd (m0109331.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v21Gh4LP022912; Wed, 1 Mar 2017 08:47:28 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=hK6lEOioMEMG/in9XrY4r+M9EhaZ5t8hgRu7vJbhA/s=; b=G5pxGfZLcXu3cTtcpuRYE664IklU5KWRera4tmtW4HeYgrQUQ5a/EACLiRQjwRnNtqnr jEd7IrPLUtICqsLfn1lg8uQ8I4Sl/6BYd26i0JlXCPnZvbCLCea6W5a8sBzrzcdryvge AK/3d+WZOC4oVfLeGlpsCQrMpwXhARJL7ZE= Received: from mail.thefacebook.com ([199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 28wnaxjdby-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Mar 2017 08:47:28 -0800 Received: from NAM03-BY2-obe.outbound.protection.outlook.com (192.168.54.28) by o365-in.thefacebook.com (192.168.16.24) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 1 Mar 2017 08:47:27 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.onmicrosoft.com; s=selector1-fb-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=hK6lEOioMEMG/in9XrY4r+M9EhaZ5t8hgRu7vJbhA/s=; b=M+9Do06ZQMomLv+HZjOWSnI7owyKqBv0+o67/jlCGVtBu1af5maaT4fXz1JqtQNQL1g98cRCWcFCKhPwW8zTSBnNvdKnNZiwlQoy40+dUk7TMnEzbvqQtv2XrqXB9LX5xFsf6crMf3jost50o81UV7HC1JTe1uaf0JDRhphounA= Authentication-Results: kernel.dk; dkim=none (message not signed) header.d=none;kernel.dk; dmarc=none action=none header.from=fb.com; Received: from localhost (2606:a000:4381:1201:225:22ff:feb3:e51a) by CY4PR15MB1912.namprd15.prod.outlook.com (10.174.54.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Wed, 1 Mar 2017 16:47:25 +0000 From: Josef Bacik To: , , , CC: Subject: [PATCH] nbd: stop leaking sockets Date: Wed, 1 Mar 2017 11:47:22 -0500 Message-ID: <1488386842-16515-1-git-send-email-jbacik@fb.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [2606:a000:4381:1201:225:22ff:feb3:e51a] X-ClientProxiedBy: CY4PR14CA0027.namprd14.prod.outlook.com (10.172.162.141) To CY4PR15MB1912.namprd15.prod.outlook.com (10.174.54.145) X-MS-Office365-Filtering-Correlation-Id: 26cce302-6538-43db-a3b0-08d460c2a406 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:CY4PR15MB1912; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1912; 3:kLCVCQlY4UGR25A/yYetNpqWOTygu/h4AN50nkoOhdtLyfCzECqy/XhGjWnFy4bOsqec41x4gdiEC0PHlOBqKza+ohBl5XWziln7j0T8sf3NlUJ9kW2lDLlHhxE4cJnWBDhPK3ejRURQ8vaW4LwrvlzHSTQDAvs5HlAAv/eg70Pgw+3H1eMDjfMMXQRgGQ6W3uuP5Pt0Z+y1vjLKSdjkT26PztLU+WtCvCSbbLWUxXA9KLcL2OI+NgZqq40/ilMwPTTZXjwBz8QUm5nsOEOpIg==; 25:Yyb4PPhWO0jEJF5A89b3MLgucxtkSXBgZcRvgTg9GA/4X98pY4Um4RBwIqFU3ppXnj9SuA2G/3FILLwodav9n0zDVnVJOTWMSMpxSsqbI0sFa8yas1UWbasEUBafFNIiSYHS5ZhiZ15ffkkaInDApet41cqtOnEujWgABq3c1erd1pS6M/LqnZ7yGNVcoay2DxFll9b6ypjNl3K8XbtgV7u81apI07LiWPlCBVXqj90ETKiDXQKqkcdURARMmuYnjx92PQ7Dh/mDAflmaXsoUT+1pxj73F4jOGmTlgMiEOFFQmcviqy521HGipJ/fTlaXfkcFXK1UaN9F/Mgr2wwBMkRr11M93EZOeTTkH1PsoS5BLuVfwedGxcbPwROcgjvBg7l6pMWUvuWDCiv6rFd6s9elh3HrQ5d/JQo+UyJW9rGkk0SyYqDe0UMfAZXPr8nqdLk6EJzzvQ1hpix6iAhlw== X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1912; 31:tBcfK77+SWNIdmfzoNo2xO0nw5VCESD+7wDPnz4KdvlfStzWSqbM1XRuHR1eG1j88OswYaynj+dqC6S5OzAJ8neM2dflBwDVPtg4NNEYMkl0GdvAgmT1iY0obumNEjntyptWXnxUjCWBnnN6394E9KxE/3v4RA+qjr+AmJGQbbBuYUg1GYWJJ6hz2xiaYp6U6FBBJd88372XgLd6Fe/wHPOZvOV2Z1Ji/cyxYVKKsHg=; 20:Lk4JAvtNo+GL9WMTPzeDKqCpKGNixBcuMHOtAZbmym2jUnBtEywunIAxZ7jU7f7KQZ1zzae6Gvgkxe2m3CPZ9y2RX5s8znGcUf3+JP/r95151QIk6bq+B9JuS1xtp1t87bU+DBA+qxVXt4t739xe7Z2McwPFgf1GzkMP53z1yk/INaH9wAQqoPOpaa7PD1/LCYuVmH3AuXyLKYkGw2LB0SVFMXIfQPTr0HsoFUHSWWbUqrY65WQbzhSq9EhMYKNTwrvD/yumTNbliuNtaqw/8/hSSb6eZApfghm1PAO/mcsriY+2zYFYo1bBWQzStrRs4hT12mIOGu1w0BiPWqb2OgI4J2bUE3G/Efgp2HmHA55Q483GEeHjYFKZ7gy5qnZdM9bhd+jY2gnOwrYN1ymqRmleJtuA1s3vkuEPL44STotHc1NkI6zq7Q6RcJNf5uTpRSx4tzO70w6XF/hEBRxgLhiyC1LHv7sEos4pJY1kBwUIL7bA6e1hScnZGtP5qh2r X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055)(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123558025)(20161123564025)(20161123562025)(20161123555025)(20161123560025)(6072148); SRVR:CY4PR15MB1912; BCL:0; PCL:0; RULEID:; SRVR:CY4PR15MB1912; X-Microsoft-Exchange-Diagnostics: 1; CY4PR15MB1912; 4:iZl+CfZpnq8uJMJK9GhpTBN/uBZV9ONRcT8CM+YeiDVK9VxiK2Lld9jy89uIlawqbjBx1l9i9/HoXX60pROP7qyQnGNqOkK/M7DHgXCQYaVX+2zACf5oBeiuVjz8b9n8iY1NiHRYPYmdzMqLkF31PLAKYWkF6QvkSu3uE5Nak6QeMHovWh1ftl3GMx0/vh9h+83ESLKOkzaIQztCNn95mGOLruNgUzwvhzvtnJ9qDNVA8H+ThBeZdB7gfPeXnJXvTn+noEECG9lVv5U8p0LNz1TWgCMRmvso6OkoLAlynqPPpek9XADxM1oAEjgGcvO22j2aKuRZY4V/qTIiM+Kjo6PD21mR0IGsLfLcs7hgSWRvIW9fg7I7k9t+ta6W+gRDtpVQXVo13zsxj7j8NRWf4G8J8EGXSUdN6IlvjbQjgQXZdb+F6tKojAKJL9ea4PeJyFXeuIVeY4pgvJ0NiDaN/+fpmr+5h2e2lUBgVd/g9duRWE7hhUmDDWgOeGacBkxy31Go7DnGmVE4LBABOzXG3EIZY0i87q5Oa0yyYtwld23eoQgCM6dgSD251wlWVTi8gS58yVNrsyKNs1tSajrhpD62uxYdy7dVin+bLafWsYLnc/61/aPirTYuLHmsIyLrGraH9dfo5P4qtfqeL+5Q5Y7nK3iTsJg3p9J8dCmZosRBSIHsYE2h4D8q9yZbBzIS X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6069001)(6009001)(7916002)(39830400002)(39410400002)(39450400003)(81166006)(25786008)(76506005)(36756003)(6486002)(8676002)(92566002)(4326008)(2906002)(38730400002)(5003940100001)(5660300001)(48376002)(2201001)(42186005)(6496005)(50226002)(7736002)(305945005)(6666003)(6636002)(189998001)(33646002)(86362001)(50986999)(50466002)(6116002)(53936002); DIR:OUT; SFP:1102; SCL:1; SRVR:CY4PR15MB1912; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Micro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C0WFgmNu5SUfEh8nP7MBsN+CGSSdos3NQQSBaUrlNrosQulGhrTYJkhBy8WlP9H4GstyaMMOfkd9aGkMQKPR1ZRqwIQ9eCNrZFJic1pVFP855XgEH26CKfiI= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 16:47:25.5871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR15MB1912 X-OriginatorOrg: fb.com X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-01_12:, , signatures=0 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This was introduced in the multi-connection patch, we've been leaking socket's ever since. Fixes: 9561a7a ("nbd: add multi-connection support") cc: stable@vger.kernel.org Signed-off-by: Josef Bacik --- drivers/block/nbd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 0bf2b21..c7e93f6 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -689,8 +689,10 @@ static int nbd_clear_sock(struct nbd_device *nbd, struct block_device *bdev) nbd->num_connections) { int i; - for (i = 0; i < nbd->num_connections; i++) + for (i = 0; i < nbd->num_connections; i++) { + sockfd_put(nbd->socks[i]->sock); kfree(nbd->socks[i]); + } kfree(nbd->socks); nbd->socks = NULL; nbd->num_connections = 0;