Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5388937ybg; Tue, 22 Oct 2019 02:27:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0XL9zu/iMF0bV/etGW3KyhO5IQESvbC1XMbLIM+5jkV2vk6HlDK5YOfDWPSSZ6yAMMS4/ X-Received: by 2002:aa7:c954:: with SMTP id h20mr17863043edt.159.1571736473770; Tue, 22 Oct 2019 02:27:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571736473; cv=none; d=google.com; s=arc-20160816; b=qpaAzB3n2r9snVg61uGIKusodkHC/BbSACde4sFBKOGp8NhFi/nG/oPL/S3XQ7MDO+ 1Ea3r0rUyp5Le6bTAomFHGq8GairkyPX67WStCcN/W6o9A0+6YCOJXwxH8T5QW7xURSO NhimYQ9trnvdIjCg0fx7eVRoujTrGP5gzYtl80gA+P6f3/3CKSxDO94CTGSp9DAgC740 NXoVsUR+SVLbCUvxfCHTmtMJpY5Ai2BVbZZ9LSiEASho0Wkv7yYXWuS13z0tXDWbnenv TaAI5NKh/C27p7Etnii4LFnZUKGsDXXNoZjkcTqiu4/UT1TVIaF1Ob0SuNAkgN+g/QUN 1CbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DdMpMJAPnmBmCGb18HjxGQhrUj1kKI9wqWAZL3wLOWs=; b=dhzFDyA3mG+OOtrFiQ7bS7qYd70UT6+huwrc6qdwPMcUsviP+Lu7uuahnfuULrRWEX A8eBDpJFDS3CwWhZrvpADrZ5rJML7RTAa97HQccLVgOPJj/SIyQYIwnWMn+tdkVBTkoK NrWKYIDymSPKQirQhHC4QQB0Pt2N3OzX5GQ59bTeCWU8ISR7XojZ9FqEuCFjcjHYTZvs eoLE33Naa9yqn/uQPXXj/xJKE8FIMrWgcCqY96KgFIu9279We3/Fnt3ih27xg5/Rc1Pe Wz8yYt9NHTYKCu8U8uCRT0YQeYZC11Xjc3S3UJ/Nx52AkHW70KuP6ry2UUevAUIuVQCT +YMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S1DWMhTY; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j18si3739443eda.278.2019.10.22.02.27.28; Tue, 22 Oct 2019 02:27:53 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=S1DWMhTY; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731481AbfJVJ0R (ORCPT + 99 others); Tue, 22 Oct 2019 05:26:17 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40120 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728182AbfJVJ0R (ORCPT ); Tue, 22 Oct 2019 05:26:17 -0400 Received: by mail-pf1-f195.google.com with SMTP id x127so10274887pfb.7; Tue, 22 Oct 2019 02:26:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=DdMpMJAPnmBmCGb18HjxGQhrUj1kKI9wqWAZL3wLOWs=; b=S1DWMhTY89ozmFHQkzFl5Q28aag2OyFasv0X7bDFv76h0glgW/z2aSTZTECEzNHTcv jko++DVwnjYdd+qOqawZrmm8AZt8Sp3b222Tw6dJM1wUwaykte2a//RI8aaRTLLjABqU uxY1LM14teSkX9WooV1VxG0h5gpCrUCUHGufzQ/Rq/oQdxRfE7h0/0pWkib4iOm3ErVE Z9PhPgW855RJD0RRSvJ+ogN73MUuXZslBBgdQFqs8O801UQpYHUrvAxreGxHFueODljA 6XO979ZFcWNrOA7oRvHXkru2vCmpExuUQhOwZpXPl3RIPcYWK+QqkT/LaUEu5wXjdKuf +SXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=DdMpMJAPnmBmCGb18HjxGQhrUj1kKI9wqWAZL3wLOWs=; b=edYBAKzg4/Fat7IOI5xf5mh5s/3bO873H53efF5wV2cHAEwkd/jab3zQu4lk44kdPh 11fTZuU2JTYrfExnWQFfniwoKWyZM3aOSwkxwPRX1b+81/rsp9HjkMdZ0QY3sn4BrV2m nJrZSxfNEKRTY5+rMlceTXM86xD4bN5Sk1CsrsJMmXVc9R3PnobQEbzbTaM+EB2a7R5l vSPc5Ll/U6YdiyX2WNkQY7Mf4Nlh0WWNe50OF6KAAPZB/PGnM/93FEM0Z1U7IB+Zgsj+ NTqdZu/EKJRsKuwdTmmoPlM4KvonVAA5v4JIkPgjEBnX8YgQY3/jAnHWHPofPDcPRX1H vrpg== X-Gm-Message-State: APjAAAUtWrNDG+5GjvK5sAq9bae1JLk+qPS7ed4336xjNDPxWbhP4+pF VHMoqfDUomytvc+q5gvB3KI= X-Received: by 2002:a63:7344:: with SMTP id d4mr2776662pgn.416.1571736376600; Tue, 22 Oct 2019 02:26:16 -0700 (PDT) Received: from localhost.localdomain ([163.152.162.99]) by smtp.gmail.com with ESMTPSA id j17sm17423770pfr.70.2019.10.22.02.26.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 02:26:15 -0700 (PDT) Date: Tue, 22 Oct 2019 18:26:11 +0900 From: Suwan Kim To: shuah Cc: Julia Lawall , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, valentina.manea.m@gmail.com, kbuild test robot Subject: Re: [PATCH] =?iso-8859-1?B?dXNiaXA6oEZp?= =?iso-8859-1?Q?x?= free of unallocated memory in vhci tx Message-ID: <20191022092611.GA3941@localhost.localdomain> References: <20191021142414.27164-1-suwan.kim027@gmail.com> <936d4cf8-cd5a-a297-8298-e9bc5d3c193d@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <936d4cf8-cd5a-a297-8298-e9bc5d3c193d@kernel.org> User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 01:28:54PM -0600, shuah wrote: > On 10/21/19 9:08 AM, Julia Lawall wrote: > > > > > > On Mon, 21 Oct 2019, Suwan Kim wrote: > > > > > iso_buffer should be set to NULL after use and free in the while loop. > > > In the case of isochronous URB in the while loop, iso_buffer is > > > allocated and after sending it to server, buffer is deallocated. And > > > then, if the next URB in the while loop is not a isochronous pipe, > > > iso_buffer still holds the previously deallocated buffer address and > > > kfree tries to free wrong buffer address. > > > > > > Fixes: ea44d190764b (“usbip: Implement SG support to vhci-hcd and stub driver”) > > > Reported-by: kbuild test robot > > > Reported-by: Julia Lawall > > > Signed-off-by: Suwan Kim > > > --- > > > drivers/usb/usbip/vhci_tx.c | 1 + > > > 1 file changed, 1 insertion(+) > > > > > > diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c > > > index c3803785f6ef..b290e810d11b 100644 > > > --- a/drivers/usb/usbip/vhci_tx.c > > > +++ b/drivers/usb/usbip/vhci_tx.c > > > @@ -73,6 +73,7 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) > > > memset(&pdu_header, 0, sizeof(pdu_header)); > > > memset(&msg, 0, sizeof(msg)); > > > memset(&iov, 0, sizeof(iov)); > > > + iso_buffer = NULL; > > > > Somehow I would have put it after the kfree, since the kfree makes the > > value invalid. iso_buffer is already initialized to NULL for the first > > iteration. If you want to put the setting to NULL at the top of the loop, > > maybe the = NULL in the first line should be removed. > > > > It makes sense to clear it after kfree() on line 150. > > This kfree() and clearing iso_buffer are necessary only for > PIPE_ISOCHRONOUS case. > > Please add a comment above that this is for isoc case. Ok. I will send v2. Regards Suwan Kim