Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2490800pxj; Mon, 10 May 2021 04:22:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRFjwNHsDmfq5ZuzD1J1hVvOz+L62UxdaPmXWT2HEDU8B/4OqfgMqETsMoz1KrGTuL6EHl X-Received: by 2002:a05:6602:2cd5:: with SMTP id j21mr18436491iow.83.1620645750722; Mon, 10 May 2021 04:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620645750; cv=none; d=google.com; s=arc-20160816; b=L8aj85lkrEUro3FQFEVgjBEBsA/3tnJpglzie2zXutOTo2yIRtz4yQ1alD6qbG91py myGOdTvR5sycxVeSrrk3jbveVfZWI6lrAK8uPrLT0ujBsvxRg2SKviDsgcEoCYKRNc33 bScvVHnae9jM1Ek2fflnvkvAlctrW4sIvf+x2WW0I0uFFwoMC0nxHxSYq8LzhD5IGiLG uedRiVI56oPl2dTw50kZmMTY9OO3zxRzA2oA5YX84+ogSjmbAKQcNj7TGvmdzSZEiB8u n0lwWJMfwPUVTvj967wvo7Xsm5SGrjNnwnRW8EJ/hMnLP/5tx6SqK1QWfAYKfdtyQwum Vquw== 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=Q5Cbcl15b3Ju6cV26FVaXxiepfxn0x3YN/YrQ7Ehayg=; b=L9iMqT85CFktobOx3jaLOcm9LKlMMH+DL6N4iq3gkTReAquUQuRS7P83vbVh/QAulN AU0BfF8vRBRsPW39GjJXPL84zg0EQvsqEOzsLAW+5ZdPeZHoV4cPXTgt5BqgrPxFCq5O +7YhxV0uhFPRevzndh8LIV0pVRGQInt7gTjbSfY69lWaXDjGEiOcP+SWDb4oPgwsukiU Qwau1/EGyvVEQdQAHHPLeoOnu+vhPdBsvwlYxIaJ85WAsNSbmzpeXBkdC+IUt3c0FAK/ ecMBlQkdqeGL9GYHi7fc6Lk4uJsHnQrteDD2v9S+C1iPUDmM//HDJ+Bqb0vRUO9hT4r9 QMjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="2hMIR/Sl"; 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 l24si14382372ioh.105.2021.05.10.04.22.18; Mon, 10 May 2021 04:22:30 -0700 (PDT) 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="2hMIR/Sl"; 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 S238758AbhEJLSo (ORCPT + 99 others); Mon, 10 May 2021 07:18:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:52682 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233839AbhEJKza (ORCPT ); Mon, 10 May 2021 06:55:30 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4594561C22; Mon, 10 May 2021 10:42:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620643354; bh=xYtFkeN39Orcq0WeEDTUJpCePQ2GI+uIcpy5yH+7+II=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2hMIR/Sl2MHCdo6TYzWxAnXXc4EGP7x30743JJF8IH+ZKrE+gaRtraG05mDX41fXA vld8aZuDoWgFqBlRqlb81R5XFWmg3mu5tjo/6G+p0YKnA2KWtTaWqn53SL0OoE7RkM 4Rph816rSHmy7ohVo/+VUgw5E7gFRXNAyfupEY+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Peter Chen , Hemant Kumar , Wesley Cheng Subject: [PATCH 5.10 282/299] usb: gadget: Fix double free of device descriptor pointers Date: Mon, 10 May 2021 12:21:19 +0200 Message-Id: <20210510102014.243645809@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Hemant Kumar commit 43c4cab006f55b6ca549dd1214e22f5965a8675f upstream. Upon driver unbind usb_free_all_descriptors() function frees all speed descriptor pointers without setting them to NULL. In case gadget speed changes (i.e from super speed plus to super speed) after driver unbind only upto super speed descriptor pointers get populated. Super speed plus desc still holds the stale (already freed) pointer. Fix this issue by setting all descriptor pointers to NULL after freeing them in usb_free_all_descriptors(). Fixes: f5c61225cf29 ("usb: gadget: Update function for SuperSpeedPlus") cc: stable@vger.kernel.org Reviewed-by: Peter Chen Signed-off-by: Hemant Kumar Signed-off-by: Wesley Cheng Link: https://lore.kernel.org/r/1619034452-17334-1-git-send-email-wcheng@codeaurora.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/config.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/usb/gadget/config.c +++ b/drivers/usb/gadget/config.c @@ -194,9 +194,13 @@ EXPORT_SYMBOL_GPL(usb_assign_descriptors void usb_free_all_descriptors(struct usb_function *f) { usb_free_descriptors(f->fs_descriptors); + f->fs_descriptors = NULL; usb_free_descriptors(f->hs_descriptors); + f->hs_descriptors = NULL; usb_free_descriptors(f->ss_descriptors); + f->ss_descriptors = NULL; usb_free_descriptors(f->ssp_descriptors); + f->ssp_descriptors = NULL; } EXPORT_SYMBOL_GPL(usb_free_all_descriptors);