Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9037816pxu; Mon, 28 Dec 2020 05:06:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJzADXExSxQ9BjYIcheSVIOZjAUshpEPYY9YPgB6bKv2ONSUy9OxM7Ebixy02wLCRcKVaVhe X-Received: by 2002:a50:d50a:: with SMTP id u10mr41566617edi.58.1609160810378; Mon, 28 Dec 2020 05:06:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160810; cv=none; d=google.com; s=arc-20160816; b=xSlVd9mP0UCqZG962dTxRalwfI/2Yv7fhw2ZrJR53w45WvUYf9zCR8swR7qmOi0j1s IK2bVBwln5L7O85OHlY2c6r9uXLmSsXafZ4eTfQIAex7Jqw0giVx0M8jRLu5AT1tPM5x X1C8f3UErV3TaQ8lZX6WXDgczw7dhcaj/8w+eiF4LAXk3mt+JbuCrX8dRaxvRMAVBkfa lU49apWr56i9EyvkvI5q8ydXMSBxzYblcZW52avW/2ZNXTwKF3AERklaLmGuZZbxq+SC g+K++aD08LrFQ8LRUFDUlf5ZrodOAuoErsM3Uwa3RmBWel6s7uvz3NOraW+g7Z+N5lqQ fwCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=uBHvo9G1HqamWcmLuAdmGv6XuT8DgUllcBsb22qr6UU=; b=B/MBlHt8/9JK7Lbgsn4C27qA3AHyp74j+78dc+bDL1oZ8aFR68OL679ZnrwOVDFBB6 1NlsCVH+7+760EKRlzSN1KZbfZdDkexlqaAjJq0dTbYE5l8y8vrWbS/mPa2Aj9Mv/vyL REHwlf0hpiviv1z6TG+gykvmktcte722vbxbSvAM3yw2JzQ1qWwrQDnxuvrv3ZDKP1A6 4zcVFRf57fz3RxHS5tjwadGT6NXJVRhg14vMF2nD6accPdyu1U0OZ1WsDNoG0hbryzkZ 2YG1fW5yJO92Zqlx9opROkAko7p84OEDLQ3zmqVuYC2w6D7xzJa6dVdzY5pKkZmscGZA aumg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zLCvQL/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si19775318eds.174.2020.12.28.05.06.26; Mon, 28 Dec 2020 05:06:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="zLCvQL/W"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730408AbgL1NES (ORCPT + 99 others); Mon, 28 Dec 2020 08:04:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:60198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730342AbgL1NEF (ORCPT ); Mon, 28 Dec 2020 08:04:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 50F0E208BA; Mon, 28 Dec 2020 13:03:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160604; bh=SsfM55E3ejQOLuIXCJFK4G7tc3KGGcQwqQuKCZgLwuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zLCvQL/WGSiczNwt4ecWRU/Z2C4SYSXuZ8hSwj/Ziydj9XRL5HJtGvctb/gvAWTsD 0/yRZ8JBminycQ7bVr9WlMIwNAAxwR3uT/2xbKn2vD2fisE8fVfxVGEr6cI4Ffne43 czKRD2IQEjNusfHWDDVMAbygX+kFkHJP5q+4aKco= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhang Qilong , Sasha Levin Subject: [PATCH 4.9 107/175] usb: oxu210hp-hcd: Fix memory leak in oxu_create Date: Mon, 28 Dec 2020 13:49:20 +0100 Message-Id: <20201228124858.436590174@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Qilong [ Upstream commit e5548b05631ec3e6bfdaef1cad28c799545b791b ] usb_create_hcd will alloc memory for hcd, and we should call usb_put_hcd to free it when adding fails to prevent memory leak. Fixes: b92a78e582b1a ("usb host: Oxford OXU210HP HCD driver") Reported-by: Hulk Robot Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20201123145809.1456541-1-zhangqilong3@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/oxu210hp-hcd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index 4e4d601af35c1..2f48da0c0bb39 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -3734,8 +3734,10 @@ static struct usb_hcd *oxu_create(struct platform_device *pdev, oxu->is_otg = otg; ret = usb_add_hcd(hcd, irq, IRQF_SHARED); - if (ret < 0) + if (ret < 0) { + usb_put_hcd(hcd); return ERR_PTR(ret); + } device_wakeup_enable(hcd->self.controller); return hcd; -- 2.27.0