Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5411807ybg; Tue, 22 Oct 2019 02:53:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqzafbUH6tCaMA8xjeXe3zGI5iZN4jA9S1oLBwrFRx+SnyKPECxwMHq+/o2HGMnEvXDYPd1V X-Received: by 2002:aa7:d958:: with SMTP id l24mr12435023eds.234.1571737997285; Tue, 22 Oct 2019 02:53:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571737997; cv=none; d=google.com; s=arc-20160816; b=bu1rsqCXHDEcKTItqU0frR4Hk7M7J1P/SH8gX+yYzojtG6Xt5GnSUuz9VKSgsVk4mq ftI3y4ISJUhUT/O425ZXR7n7dU5Zh6hkOttr6CB+p3ZdY+441Er7qpM5iUaDT1VI2N0X i6qm7Mb/Pq7J1gy2f/1aDdLgz6YeL7BhEHO1nSmDgQHu0mVTAbDhvm40rbd+XMsKw9tE Os66co195lpzMt/3t/HgcwZ3rhz8ODR1WUOv6g+cKm1V8+iLYM0LtAs9A7Bkb2m4M39H kBLGjzJTCrkAZqoG0wsYwm4ApaK5LCXTSVhgGQBzFVtiwhFakQWNWs1OVVT7/PKG3F/y NzCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Epy4pXnKiue3r7Il9XvBJ55INxdB0I61F+uLoUuMhN4=; b=bCmk3CUYYRFfBqvk8kCWoCSIYRBOK9OVbAsK6TNwMHsJ7XsNpE09uRfv5Wvp5j/fkn d8XXqoP6sQ1vAlT/usrPndXaZ8sdpjsLpx/vJZbVPMBvTSl1U8AV59VvXo4+gEjtSEi4 VtzL4AAZ/hWIWVmexJuHadQFkEWLuQ1kfVZaLUoN/hVgt1VEV8WFmf4bRjCkuNFP83eS +sqUzHVbbNnWey3a7l1V7ZuFfCtsInJZuIA8MZsxocjPpvzwLab+TNkgaBvdbMsQhoUg XEBSMIQwDA9vwJqdIRcSiS1NxWLYigGxo/fWdzvE5KanP07k6hIDisye55urnuV5qIbo 6itQ== ARC-Authentication-Results: i=1; mx.google.com; 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 t10si11186444edd.447.2019.10.22.02.52.52; Tue, 22 Oct 2019 02:53:17 -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; 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 S1731602AbfJVJvy (ORCPT + 99 others); Tue, 22 Oct 2019 05:51:54 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:42452 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731220AbfJVJvx (ORCPT ); Tue, 22 Oct 2019 05:51:53 -0400 X-IronPort-AV: E=Sophos;i="5.67,326,1566856800"; d="scan'208";a="407444175" Received: from unknown (HELO hadrien) ([213.174.99.147]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2019 11:51:52 +0200 Date: Tue, 22 Oct 2019 11:51:51 +0200 (CEST) From: Julia Lawall X-X-Sender: julia@hadrien To: Suwan Kim cc: shuah@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, julia.lawall@lip6.fr, valentina.manea.m@gmail.com, kbuild test robot Subject: Re: [PATCH v2] usbip: Fix free of unallocated memory in vhci tx In-Reply-To: <20191022093017.8027-1-suwan.kim027@gmail.com> Message-ID: References: <20191022093017.8027-1-suwan.kim027@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 22 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 Reviewed-by: Julia Lawall > --- > v1 - v2: Move the setting NULL after kfree() and add the comment > --- > drivers/usb/usbip/vhci_tx.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c > index c3803785f6ef..0ae40a13a9fe 100644 > --- a/drivers/usb/usbip/vhci_tx.c > +++ b/drivers/usb/usbip/vhci_tx.c > @@ -147,7 +147,10 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) > } > > kfree(iov); > + /* This is only for isochronous case */ > kfree(iso_buffer); > + iso_buffer = NULL; > + > usbip_dbg_vhci_tx("send txdata\n"); > > total_size += txsize; > -- > 2.20.1 > >