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=-10.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT 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 A2B72C433E0 for ; Tue, 23 Jun 2020 20:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7298F2098B for ; Tue, 23 Jun 2020 20:47:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945277; bh=fo5IicuzVZcxkY15Ztxrcpm6Hb1BOiwqofyzoKjdMBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=kiPZlRipGvMzS8gMUjx6wlyYyHz5u7S4bBlODsvip0riDsu11viZ69aLUrliU/4nW gbPLwnsQeqp+lV43sza8fm32s5ffEiOfIkkE/vbcTnciPcc3sATChYgYEhILaZAapV SZvdLEBU6rjK5oyJP8pAjFi+oRaeiaIm73OWcEhk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392915AbgFWUrx (ORCPT ); Tue, 23 Jun 2020 16:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:46414 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404079AbgFWUrr (ORCPT ); Tue, 23 Jun 2020 16:47:47 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 482D121548; Tue, 23 Jun 2020 20:47:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592945267; bh=fo5IicuzVZcxkY15Ztxrcpm6Hb1BOiwqofyzoKjdMBk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tmj/PCkygy6axZMSlYMLZSKWrzMyEV16JNCYu/Ok9wtsqRyh+M989nROtA2dBeYF2 4RnpPcLmcWTHqC2n2f4UxsBZLKd8dN57X9sARvrveuocfAJRRlDvpjLmZeswX7t5ci E8J0YpV+YLl7ZwF5E+W21WSJ33BT9Q/3ClbQCM18= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Qiushi Wu , Felipe Balbi , Sasha Levin Subject: [PATCH 4.14 074/136] usb: gadget: fix potential double-free in m66592_probe. Date: Tue, 23 Jun 2020 21:58:50 +0200 Message-Id: <20200623195307.401290675@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195303.601828702@linuxfoundation.org> References: <20200623195303.601828702@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qiushi Wu [ Upstream commit 44734a594196bf1d474212f38fe3a0d37a73278b ] m66592_free_request() is called under label "err_add_udc" and "clean_up", and m66592->ep0_req is not set to NULL after first free, leading to a double-free. Fix this issue by setting m66592->ep0_req to NULL after the first free. Fixes: 0f91349b89f3 ("usb: gadget: convert all users to the new udc infrastructure") Signed-off-by: Qiushi Wu Signed-off-by: Felipe Balbi Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/m66592-udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index 46ce7bc15f2b0..53abad98af6d8 100644 --- a/drivers/usb/gadget/udc/m66592-udc.c +++ b/drivers/usb/gadget/udc/m66592-udc.c @@ -1672,7 +1672,7 @@ static int m66592_probe(struct platform_device *pdev) err_add_udc: m66592_free_request(&m66592->ep[0].ep, m66592->ep0_req); - + m66592->ep0_req = NULL; clean_up3: if (m66592->pdata->on_chip) { clk_disable(m66592->clk); -- 2.25.1