Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1158780imm; Wed, 1 Aug 2018 11:09:07 -0700 (PDT) X-Google-Smtp-Source: AAOMgpebxGnASWA8DDHmQA0M8T7j7XKS+gUcb4H5YcsJewcemnfvI1Ix1JYr/k0KToasxpHBmnjk X-Received: by 2002:a62:b29c:: with SMTP id z28-v6mr28211309pfl.8.1533146947677; Wed, 01 Aug 2018 11:09:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533146947; cv=none; d=google.com; s=arc-20160816; b=RchTHsWKwMiK/VJq1IycpA19S20YWgXu6tMruH20fRvIKFeJwXLKPVpXjN9wWptzaK 8GLXnUODbNNdpCFByh8vgRmzpR+Q9pfwm/e4vgfRKc8xzv6NM6XFQrfAVJIJ8y7p7D3G kQTSjLLyK/eRad+pMBEmLisGRbTs1GvWvI7Jfq+mONFPV2F79MTm5RN5N4OZa7joS1t6 HJzbySYYoAgGd5mdxgJ4XxHYL61oAOpkYIh55jWF09++jzPNIckH1zogMC9IHmku3Giq NURcJOPVmtN2LKEtqyqXUEmHT6/xJE9+bEDpJkQlaBVAxb4qhUPqsGvi+K8aUcydJis3 /Z0w== 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 :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=8TLDjE5fF/7qoBoP5jiZhh/hnuOwvbR1/W/F6EJc/uo=; b=sx6lasF7LPTO8GqTVoVd4aoEwug5P9fLbD1nyDu1Db+2Wq2cwOqeEzYBjsZfJpuSMG bHgizbtDUKtpix7V6ipd+/bPhCmMkqmNUTWxEoyu0aetGkj2Y6nMqw3Uf3nC537rysqK Zbw/8xltioLp1MSDb2cUYsYlebkNEGTyWVsM80kAFqEGoHPVNTfX7X0g/zuya2IEntE5 X3g6RenAD7kdYAJKojWWSCNLQVauc8ABqiMXJurYfZCbHdPchbLuKbRy+MO1IRUHZJIj GmZR1weIik9x0cNtie9dOM+l6gLbLCwcrG9AjNDQaxxH+mbgT2LxP6nePBkv3DjU9a3B Hieg== 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 p9-v6si16769898pff.30.2018.08.01.11.08.53; Wed, 01 Aug 2018 11:09:07 -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 S1732400AbeHATyU (ORCPT + 99 others); Wed, 1 Aug 2018 15:54:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:50156 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405800AbeHATIg (ORCPT ); Wed, 1 Aug 2018 15:08:36 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5F42F13C8; Wed, 1 Aug 2018 17:15:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Shuah Khan (Samsung OSG)" , Sasha Levin Subject: [PATCH 4.14 063/246] usbip: usbip_detach: Fix memory, udev context and udev leak Date: Wed, 1 Aug 2018 18:49:33 +0200 Message-Id: <20180801165014.723417817@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: "Shuah Khan (Samsung OSG)" [ Upstream commit d179f99a651685b19333360e6558110da2fe9bd7 ] detach_port() fails to call usbip_vhci_driver_close() from its error path after usbip_vhci_detach_device() returns failure, leaking memory allocated in usbip_vhci_driver_open() and holding udev_context and udev references. Fix it to call usbip_vhci_driver_close(). Signed-off-by: Shuah Khan (Samsung OSG) Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/usb/usbip/src/usbip_detach.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/tools/usb/usbip/src/usbip_detach.c +++ b/tools/usb/usbip/src/usbip_detach.c @@ -43,7 +43,7 @@ void usbip_detach_usage(void) static int detach_port(char *port) { - int ret; + int ret = 0; uint8_t portnum; char path[PATH_MAX+1]; @@ -73,9 +73,12 @@ static int detach_port(char *port) } ret = usbip_vhci_detach_device(portnum); - if (ret < 0) - return -1; + if (ret < 0) { + ret = -1; + goto call_driver_close; + } +call_driver_close: usbip_vhci_driver_close(); return ret;