Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp735414ybc; Tue, 19 Nov 2019 08:26:04 -0800 (PST) X-Google-Smtp-Source: APXvYqzCgeWZk4Nfsh6iWysSKYOIzLg7j/8TPcwkA3rsTnceynV2eADUg9quCerqUsCfkn8Vlcrr X-Received: by 2002:a17:906:1cd8:: with SMTP id i24mr35823257ejh.149.1574180764011; Tue, 19 Nov 2019 08:26:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574180764; cv=none; d=google.com; s=arc-20160816; b=yVAm6qohc01Oy9Z7+A4NfWfuDaa3TfHLHxfKviMTZspQWU0oIHSxxNyM8sx0LYCzAH a64nl7gn6yWa3M9DwMmq82qoxp96OVqUApwzDjG1iD+hxJHycdD+9cF9MiluG5PYV8Gp gAQ1lHqeOxqr9scoeS7jB9FtBWWBgkPmFb3tupTzqfrlxyMiGt2HC/MxO0s9Q/i1LcrM l+BqMSq3j/o0eYLa/rn0PEdVS8kpueNr4MQN8oLgNTJaLKftpnafZLHVFW4PtKppdICF VKEl99LlQ0djBEo0vSJpCWUoQYCv/QaQDCBKk+RkhfXJRsfEhvA11QwyuXQP79L5Rqr3 MXfw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=7xBPbB0l5zXDQJ0ykS2pcsoh3Vk0x6ZjZkqP5G3hnUM=; b=LYNaPBB2ZeBp1HXGxWq0r/u+w7C5yHKFTx/hFEaZH8RsckdmhsOlW2f/Bzq9GDFfN+ RRUrieUbojw278cR81odzscHsmnfLjsfgL2qlQ1nPmU6oCL9KimpH8y4Fm2Mi3iCzPKL vkO+W9YLZDuGw+tTPSaPbWasC6VDKJi7LSv3MeDrrQnAl92hWEVmaY2jQVujULCaPkqj /nakGOHooP10EGAZ5SjFOMI+xVsSn27bobYJXTPCDfWon51KHs+bmM2qwpII9vvuy0ck 6zd5sVtA4elfXDeTMf1R7VpUe0cqlNzps1Nhwc7RkaH8p7ePOUaK2znuTZAsa8QjtqGy yWJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20150623.gappssmtp.com header.s=20150623 header.b=Sm8z1kAp; 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 n2si14777641ejz.65.2019.11.19.08.25.39; Tue, 19 Nov 2019 08:26:03 -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-dk.20150623.gappssmtp.com header.s=20150623 header.b=Sm8z1kAp; 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 S1728482AbfKSQXx (ORCPT + 99 others); Tue, 19 Nov 2019 11:23:53 -0500 Received: from mail-io1-f66.google.com ([209.85.166.66]:35975 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728203AbfKSQXx (ORCPT ); Tue, 19 Nov 2019 11:23:53 -0500 Received: by mail-io1-f66.google.com with SMTP id s3so23889923ioe.3 for ; Tue, 19 Nov 2019 08:23:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=7xBPbB0l5zXDQJ0ykS2pcsoh3Vk0x6ZjZkqP5G3hnUM=; b=Sm8z1kApGq1YRmDHN+gWoe8jgDmvwDTCFFbiUOE1ZzL8UwxD3CHaIoj+U5vroJWotn Scut8GZMnc8ZVRAlIPwAPkDombOWJhIA00gLfMjNYwogATUHyj0IBnX8faNEHJg5o8ca gObf0a+uUbqjo+e6kg0rH3OXqyinmg1Rg8+uGrYDl2GhtmuOFwEm8YpOIyPpKPvfrFpb lIkft9nZX3+00p4t4ppCCYYsyrmw5CGl6t1i6z2UeK2K79X1yq33aKR0DkCeaKTCXlNS TceACMWTRkXkyzpznWBS38sjIeR0hM6kullpYZnPiDZ/0omJbyifVdCf7/AeK4ILPBdj meGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=7xBPbB0l5zXDQJ0ykS2pcsoh3Vk0x6ZjZkqP5G3hnUM=; b=TkaBvuxK/iRUh8olwhv7C8c6IdRgskQQorYBVB46Xo4DcxGoYaNSQEpVg4VJpEYcqV 7I06rxgYxi5b+Ph2wJtDw04gmIZx0xgvFDFVzKYqJKuU4vKzDtr0n/mBhHhc79JzS1mg qOvAbJNAtWFwS61gIQiHsaG+lFzPZXsk0ClWN92N9Vv9J0TB5womd4c7T3ZNjEU6LYFZ 4GbRYACDt2s/UQFXxV8fzIyEBaeiOePCD/sjVCO1nhv//7dkLD/+TStT7xPx8zKOJzj7 yXGhrNZwOgcuKf4nDJb+SVdX8Wmv2u2SS9e1W9+sbklMscB16OAMprT1a/rPGCwwiaDd /Arw== X-Gm-Message-State: APjAAAWYezuIbX1RdPEh8KbN7a6kZqzdz6nUz0/hQljR0VlpLZYfuA4G DRgCB11I7lVIAJgv0nhuNqS/pw== X-Received: by 2002:a02:40c6:: with SMTP id n189mr430847jaa.18.1574180632196; Tue, 19 Nov 2019 08:23:52 -0800 (PST) Received: from [192.168.1.159] ([65.144.74.34]) by smtp.gmail.com with ESMTPSA id y8sm5611174ilg.47.2019.11.19.08.23.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Nov 2019 08:23:51 -0800 (PST) Subject: Re: [v2] nbd:fix memory leak in nbd_get_socket() To: Mike Christie , Sun Ke , josef@toxicpanda.com, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org References: <1574143751-138680-1-git-send-email-sunke32@huawei.com> <5DD416DB.1040302@redhat.com> From: Jens Axboe Message-ID: Date: Tue, 19 Nov 2019 09:23:49 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <5DD416DB.1040302@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/19 9:22 AM, Mike Christie wrote: > On 11/19/2019 12:09 AM, Sun Ke wrote: >> Before return NULL,put the sock first. >> >> Cc: stable@vger.kernel.org >> Fixes: cf1b2326b734 ("nbd: verify socket is supported during setup") >> Signed-off-by: Sun Ke >> --- >> v2: add cc:stable tag >> --- >> drivers/block/nbd.c | 1 + >> 1 file changed, 1 insertion(+) >> >> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c >> index a94ee45..19e7599 100644 >> --- a/drivers/block/nbd.c >> +++ b/drivers/block/nbd.c >> @@ -993,6 +993,7 @@ static struct socket *nbd_get_socket(struct nbd_device *nbd, unsigned long fd, >> 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; >> } >> >> > > Reviewed-by: Mike Christie Thanks (both of you), applied for 5.4. -- Jens Axboe