From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0F492CA9EA0 for ; Tue, 22 Oct 2019 09:51:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E50D6214B2 for ; Tue, 22 Oct 2019 09:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731470AbfJVJvy (ORCPT ); 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-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 > >