Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp858774ybt; Wed, 8 Jul 2020 13:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/+btQW7zPXS43pdVpLcZV7rJ0wAcGIscIqbg1Os5nHba/3bOxcQTfzJ0/GeKGut7OHR0p X-Received: by 2002:a50:b022:: with SMTP id i31mr70425981edd.301.1594240479146; Wed, 08 Jul 2020 13:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594240479; cv=none; d=google.com; s=arc-20160816; b=ojfJifc8oQBwgAy7VN9CGh7tX5WAdcyKegrks7CzRNkveU/SEBWNPLXaYxFPNoIRKv fzHZ5JRIIeCJfrrxWeXUU3hA97FetZJClNe1/SXt7Ky50WMtcxFEA93mGKn0VOgnAfl2 dc+FyUOifqYmQbH26kSpu1hwWrx1L4HGbwT8P2vUhgMOAffMmN2+7ZeF/2f+knAtlL7E WhGJ7kN34B4AFLDxR3MaxkJVeRux0rjARFoJE835DAalbTeh1aaDJkJp3iCsAPGCQ+ON Dh+RQ4ARbuOwb352sBF3O3gbln/IRugyOTleHnpgSOpmuZIWgXXFioQvT9R2QFmJRQDZ YQ7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=l1Qa8OzwAR6GZw2Yyr8nqVEuaO5U7rmz8TRtONN6kXs=; b=rhy+iAEYx+DknWFnhVqaunnif3HeMC3x+BjSZoJtzS0tcYSLKZ0Op2D6YpV9O0BuQw PbMXbpy57Bq7xw3OjbQrjFHiupvoOXYVuNMdYU+X2O/MXi35Qsl24rrDsUzmQLPWV/RD +y0OjyPoGgnGiBSQrrzCBqtcgx1Jk1aIeUOPwoqkM8FAfxSW2a0xJlwkoPXNAt+s5T6l Wb7pUmFAwBcjPn3X+cNC1WfGf5d0dp5rAhE/6qalJu6ufIsWdFjaW/vlqKCwDdLaTxow 1Qf8P2+Pu1KRRG5gfn1+OIegKnxcMFTxDCaCxtsPfmLOH8DaLqRgNW0NQ9PgK07tv8/Z dqVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qhUtPzDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si629373edq.32.2020.07.08.13.34.15; Wed, 08 Jul 2020 13:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qhUtPzDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726044AbgGHUcG (ORCPT + 99 others); Wed, 8 Jul 2020 16:32:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:39156 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbgGHUcG (ORCPT ); Wed, 8 Jul 2020 16:32:06 -0400 Received: from sol.localdomain (c-107-3-166-239.hsd1.ca.comcast.net [107.3.166.239]) (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 E36BC20720; Wed, 8 Jul 2020 20:32:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594240326; bh=Phr+m9logqBbeGjOMUdUtNLbZiR9Q8OLEMn3mWsvao8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qhUtPzDPYysvTjVFW40ey+9VkdAW+90/1lX07VNQuDb78Itivr4ZHuD275dXwOn3G mjFs3V/IUr6W+IeM2I2eq9sAABwc7wOdgftlw5Z7FMpAuJ0n4TOCGBWYPXXr9HOy7F bZwnwfQtdxk6h5um4Jel7s91n9ksWc0qNt/vduSA= Date: Wed, 8 Jul 2020 13:32:04 -0700 From: Eric Biggers To: Zheng Bin Cc: mchristi@redhat.com, josef@toxicpanda.com, axboe@kernel.dk, navid.emamdoost@gmail.com, linux-block@vger.kernel.org, nbd@other.debian.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com Subject: Re: [PATCH v4] nbd: Fix memory leak in nbd_add_socket Message-ID: <20200708203204.GB35321@sol.localdomain> References: <20200629012349.26641-1-zhengbin13@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200629012349.26641-1-zhengbin13@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 29, 2020 at 09:23:49AM +0800, Zheng Bin wrote: > When adding first socket to nbd, if nsock's allocation failed, the data > structure member "config->socks" was reallocated, but the data structure > member "config->num_connections" was not updated. A memory leak will occur > then because the function "nbd_config_put" will free "config->socks" only > when "config->num_connections" is not zero. > > Fixes: 03bf73c315ed ("nbd: prevent memory leak") > Reported-by: syzbot+934037347002901b8d2a@syzkaller.appspotmail.com > Signed-off-by: Zheng Bin > --- Reviewed-by: Eric Biggers