Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4667286ybg; Mon, 21 Oct 2019 12:29:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqxoWAKwh/pHMSL8JQy/7QPRHhewoFcw/Fl5hHlBSpa4dwHFWctqghdZno9ajej9ke+MjTZJ X-Received: by 2002:a17:906:2961:: with SMTP id x1mr23758110ejd.91.1571686181136; Mon, 21 Oct 2019 12:29:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571686181; cv=none; d=google.com; s=arc-20160816; b=ghIPhEdrwzmZ1WtIToxV72ckdzlkq00Rvgnd91U+nc1MXdJDTiJxqkEqFBo+FnOiD1 Sb0mFAQWzHMJAyQ0qEg099uprTJaKFqyPjfasrvcl0qJEVjsuz1crT5TSqER8brqXS6j tp0o4Zr0yvU5wbI9y2HapmqzLGoTSDqqOQBKxR1KzDwWZSoCG3nW90PCYDVj+7ntbHkp CsuRqhT0P+JTrsCNdQb3GhXrEEgHteqNaZ8Hnzl5yWixNd1OOjQGVLnTxwPU2ejdbz66 WFkeeOpXRsNdWFn04WguT3wXZwDIxPJY4XT0sR0o9s8UA/KnQVmSGcUiWOaR0dxYtAN2 RqLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=RHvp/U5ze3lrOU4bmzTUAxNm0AbZ7aUiNH8k0bpErf4=; b=LJCwuWkt7M9C95eLeOxg45R0xGsr4wLVS4IrOHutnL9tIld5i14gsoXf/ao15XVlTt ULs8Jg8Bpr2gPP5Q04vgx7EOToHRgTw1yDYz3O/RZZPZELT234l9jebZsyVekE2vMtZ8 VG3tN05agY650CajZR9+KU62I4UOxnBB8xBUWWkHFqqbil14n/5b9fvaM2+quSuu7JPw 7J3C1oZkGlbcG5kiFNn3wepp9zupiHXa2z/y3aVJ5OV99/DXWU15GVveqWrniDCPeMjM SzcuPBMnstQpx4l4gHI+cDkRByRsNpmqjuuPux9ST7E9ATH+Q02JPyS/eg2sZmcXUmwo MvnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=sMH4Csq9; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g22si10708460edf.398.2019.10.21.12.29.16; Mon, 21 Oct 2019 12:29:41 -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=@kernel.org header.s=default header.b=sMH4Csq9; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729894AbfJUT25 (ORCPT + 99 others); Mon, 21 Oct 2019 15:28:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:58054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728375AbfJUT25 (ORCPT ); Mon, 21 Oct 2019 15:28:57 -0400 Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net [24.9.64.241]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 97543205ED; Mon, 21 Oct 2019 19:28:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571686136; bh=aL519NiYCbs7aj+hNkciLs7n+wrEjTqYqKNI1l5QCAM=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=sMH4Csq9dBDHCKtTWRpR3hDjvXzW8duYFGeq1M984poBAFdjZ9OjMxIaLqGidbAMS hsryK3KEsHntoMDQGMiP4jimYIGln/4CQZfmhLvnmWICsIWDu+dlvnWy10R1ZP0J/u 0lHczooeberiJ8lt4QRhv51tMzK7M0QlAlkLNn5Q= Subject: =?UTF-8?Q?Re=3a_=5bPATCH=5d_usbip=3a=c2=a0Fix_free_of_unallocated_m?= =?UTF-8?Q?emory_in_vhci_tx?= To: Julia Lawall , Suwan Kim Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, valentina.manea.m@gmail.com, kbuild test robot , shuah References: <20191021142414.27164-1-suwan.kim027@gmail.com> From: shuah Message-ID: <936d4cf8-cd5a-a297-8298-e9bc5d3c193d@kernel.org> Date: Mon, 21 Oct 2019 13:28:54 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. thanks, -- Shuah