Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp736489ybc; Tue, 19 Nov 2019 08:27:08 -0800 (PST) X-Google-Smtp-Source: APXvYqxSatHIX3YjLIkSOxKf9DGUx1Q0lGB/wRA9IV7RVwSM6ygG9hIiGmYp30IdaDvD1Tk+Gxo9 X-Received: by 2002:a17:906:4dd5:: with SMTP id f21mr35698253ejw.203.1574180828480; Tue, 19 Nov 2019 08:27:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574180828; cv=none; d=google.com; s=arc-20160816; b=yaEkVAaEWGeKaa8Ba4rJP8wKqGuBljzSrFSVp20ZOBQDeViyAn0KMWucNxkU83A2f5 ElwjeaCF9OOFu8WgcGMjeptja137JiupD9IwtUfv6uAIhQtyXfzgmlVAyeseJE64DC4e D5xaqm625XY8y54wz4wQ9UqzDUdm9rFnSeMn/wh97l8lg9mozQi7QS/R01ENNn/gKN3w p9djyxmd3ETldjdmaxtcAu7f4O5/kVC+l3lQ5pqJGqY2BUbXZxzbjon4THH5PRDW3JtM +8cJ69kJE1KmEmIDs3ihlelmWkPRHGnR8dolOg/+xsDZkwsst3WOIr84i3QBY3tf8qoM 0Vzw== 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:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=9dqMi9w8FGMz0iOTrsEVSdaPR96qMxP3SmDt20AyNaA=; b=g4n7EXubKaDAUzesGK1/R5EluZCVWYEiQ83Rntp0jWjmFMf3ZZtZApxAryJ4RFJ/6I XWiCgLK3CoKypjGqHqPF7e8wyHkA6HvyUViraAZPZ/tEi7vWoJs8TWV98VxcsusJCYkQ 2B3CCztb9rJ/PHgEhWQMGdXW+NCQgRPNVqgdxVezAkflDP0QXfCCwRlheuzMNTJc1nB7 gmmpRHVMlW2hERUq9+Djxcn322a+HDAlDy+8GVQvpFwj4Z4vvg6qCC8U66+8yAA7Zn1+ Sy84RoRpe530fNQfyi1qgIui7Ez1jHjJHCLk0FO3XZe7/R3FYYKxRXePV+BxOFQuqrkl 6OPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YCWenkjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si13506073ejb.379.2019.11.19.08.26.44; Tue, 19 Nov 2019 08:27:08 -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=@redhat.com header.s=mimecast20190719 header.b=YCWenkjt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728520AbfKSQW7 (ORCPT + 99 others); Tue, 19 Nov 2019 11:22:59 -0500 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:22167 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727560AbfKSQW6 (ORCPT ); Tue, 19 Nov 2019 11:22:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574180577; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9dqMi9w8FGMz0iOTrsEVSdaPR96qMxP3SmDt20AyNaA=; b=YCWenkjtBbg6mjmkweV+uhkNdCoBHEnmrjPdbMPNvlyGm3B75Z7/8WnTX3MH1PzzpIHrnH WZmcZTHTaispbmJfczfFgnocKi6FyO9owHYE/hR61jJnDcxjo48EWnrZO10igBrtx/y8kB VENF2wwtYEGcFAS15T4vW2U/ti7nQBw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-168-UanJR99WNNSuLTN67p4xeQ-1; Tue, 19 Nov 2019 11:22:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E3338018A1; Tue, 19 Nov 2019 16:22:53 +0000 (UTC) Received: from [10.10.121.199] (ovpn-121-199.rdu2.redhat.com [10.10.121.199]) by smtp.corp.redhat.com (Postfix) with ESMTP id 361F55E243; Tue, 19 Nov 2019 16:22:52 +0000 (UTC) Subject: Re: [v2] nbd:fix memory leak in nbd_get_socket() To: Sun Ke , josef@toxicpanda.com, axboe@kernel.dk, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org References: <1574143751-138680-1-git-send-email-sunke32@huawei.com> Cc: stable@vger.kernel.org From: Mike Christie Message-ID: <5DD416DB.1040302@redhat.com> Date: Tue, 19 Nov 2019 10:22:51 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1574143751-138680-1-git-send-email-sunke32@huawei.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: UanJR99WNNSuLTN67p4xeQ-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/19/2019 12:09 AM, Sun Ke wrote: > Before return NULL,put the sock first. >=20 > 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(+) >=20 > 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_devic= e *nbd, unsigned long fd, > =09if (sock->ops->shutdown =3D=3D sock_no_shutdown) { > =09=09dev_err(disk_to_dev(nbd->disk), "Unsupported socket: shutdown call= out must be supported.\n"); > =09=09*err =3D -EINVAL; > +=09=09sockfd_put(sock); > =09=09return NULL; > =09} > =20 >=20 Reviewed-by: Mike Christie