Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4380095ybg; Mon, 21 Oct 2019 08:09:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyB1MpI4L3kLitcdkIYd7CRXBfOLtZoYxY6XW2Q/b0ztfOqzm9id0Hm28+A8iJXdl4bYNaA X-Received: by 2002:a17:906:11d8:: with SMTP id o24mr22647105eja.224.1571670573716; Mon, 21 Oct 2019 08:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571670573; cv=none; d=google.com; s=arc-20160816; b=PBMmEe8Z7IE2To9Hbh+bOyEGsq8LBHe80/TaOwWD44R9v/2tFlt8I1wiY81gTdL26s piphe4vTHPTP+vZv1BrBTSDZliTS0UXBszzirVhyG1wfoc7SH36WX0i4C7flItUbiDoa a4VCRuXji7SOqj0zR+v2BxfaDgdmNl2qPMKNxGkYW1pM6gxcqGAIrWL9Hb/bAXKYKTS9 pLzO6ZViAt68ULK1v7y4rok5mLVX4nArRCxrF2KWS46supaEMANA+DTJubKXRJO0Kt6O 4a3sWL3kfCPqYACslY0p81qEcY4IRXcmS1F7KgnF+20bRicGHLzA0yHytlIw5hw3wMoy vV9A== 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=G+1rJQAzakMXKbbBDgoyec4mfaSncnqJZeagpVPjSUg=; b=A79Jn+lamP8L+abbEQfLYaqJsZ2ViFE8g43IK16Wv+SlPuP9nZ1BEbqq5oumpPBGMY ptzHgogPzhsBmZo3mKS+WI/as1RRaogk5EvOBiv02hK6NTOiipuIu8iHHh724eKb4pBi ETejp7PktRr8D4GjggMw9IJ7gFMF8OlNBsUWD01edXG70w3+z1/kndBpsyMvdz4JZN3l DUuxuiv62srGfUreir7jtOdtuImW41casaQ2CgNLPQnxa1NjZHCfJmBxu4vK1BtC9pWF ztbryuUiVde2BR6A4yiqFJ8WY8OoD/k+tfrKV4RsDdQSc3eCdKkf/SMaJVR1xYIdtFyu VErA== 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 v31si9845621edm.402.2019.10.21.08.09.07; Mon, 21 Oct 2019 08:09:33 -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 S1729528AbfJUPIH (ORCPT + 99 others); Mon, 21 Oct 2019 11:08:07 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:19476 "EHLO mail2-relais-roc.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726847AbfJUPIG (ORCPT ); Mon, 21 Oct 2019 11:08:06 -0400 X-IronPort-AV: E=Sophos;i="5.67,323,1566856800"; d="scan'208";a="407263396" Received: from portablejulia.rsr.lip6.fr ([132.227.76.63]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Oct 2019 17:08:04 +0200 Date: Mon, 21 Oct 2019 17:08:05 +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: =?ISO-8859-15?Q?Re=3A_=5BPATCH=5D_usbip=3A=A0Fix_free_of_unallo?= =?ISO-8859-15?Q?cated_memory_in_vhci_tx?= In-Reply-To: <20191021142414.27164-1-suwan.kim027@gmail.com> Message-ID: References: <20191021142414.27164-1-suwan.kim027@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="8323329-480209675-1571670485=:2877" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-480209675-1571670485=:2877 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT 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. julia > > usbip_dbg_vhci_tx("setup txdata urb seqnum %lu\n", > priv->seqnum); > -- > 2.21.0 > > --8323329-480209675-1571670485=:2877--