Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3766889pxt; Tue, 10 Aug 2021 10:50:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzL0nqjEPghVvWj+KhUPISYcwVrHxnXlI3sl4kvhTkFl4NMmCmnOppmcAYx8Tj0mqi9Qfum X-Received: by 2002:a92:d992:: with SMTP id r18mr42669iln.304.1628617818979; Tue, 10 Aug 2021 10:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617818; cv=none; d=google.com; s=arc-20160816; b=WoVMv2vriJ1eqnWYdkZhFMuFfN7Tf3jrTqN9WcAhX+6UeT/Mo1Mcv4jDQnadf+Z65z 4EwZfLC8E45ibcJC+GFL0lide0ZuUTrZ84A6+riyoyGVlVR99psodgjEBMdEoBTNiWH1 /A6Ng3iZB5vCnnaasS22eU+Rm/Tk25TuIkH7gcPwzgLT81LJHwc5krNNNmNlVZwtDwca jzzeWN5bHSmATaCxSDPJNzCQg0gQqr6C3PiSMQIKLQn04hAVkwM/FRthVyKMc1BaixvZ 1lADHZ1Y8mUxg4hLXfktasG8DaxWMrS8gHjwqsBTWa5SsBLXkQXSfEv9t8xSSSaPRbmk 7xIg== 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=xwqYcuuV4+dd3WuXp3pw53RhllEyu3KApB9GHpNnqbM=; b=FLYaBfsETAs6LB+8nbZ8u3G7VamGwYjbt3qBCLQjnBkE13h6qRULjerGf2vTddlB+K P8bS+quETFjaHKZwGtPtXwyzp3wF2h6nfStfk3mgrNhf66W5G0CIA3MrrD7ZNgAx9fcO nPlnkkfAQrTpJuDaYK+QU9MmtnSjvMZ6kpkF+oget4gLCUDAhDLiU9G9/qQjrO5Cw44z 7QcxdYfaT/PAt+XQWrcRPTTWtYuiFDLEuBUFKwbLFBrFEQ2RiHwVHjuDpBT5uXnjJnzu rjE1BvNyRe2i3XF2Ie/HVktWydykqJZAFQkDFEQRPR4IrwCHMbJYNOCih8ihRHaG11Zj yzbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IUn+tZW7; 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 y5si20856784ioc.20.2021.08.10.10.50.05; Tue, 10 Aug 2021 10:50:18 -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=IUn+tZW7; 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 S235103AbhHJRrq (ORCPT + 99 others); Tue, 10 Aug 2021 13:47:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:40452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235770AbhHJRnf (ORCPT ); Tue, 10 Aug 2021 13:43:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 933C860FC4; Tue, 10 Aug 2021 17:39:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617149; bh=2Y3Qp3G5mENTpc2REOidP74dQvh1947DMC9bw/PxA+8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IUn+tZW7CxcMH5bGR8wQfqGbyTa2o2yVUS06DkuyY7WixTRMFmdCS6Qh/nyao91h/ T5gJo0oy8VqPCqZ7vYR0+s4FcgedQksNir61wBcV2z3Gbqo/LpLO/hNNm1994GNwYR LKBuvVh6Ut7mIREAzYKWkCvHj05MlSSm4ihulT58= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Felipe Balbi , Zhang Qilong Subject: [PATCH 5.10 065/135] usb: gadget: remove leaked entry from udc driver list Date: Tue, 10 Aug 2021 19:29:59 +0200 Message-Id: <20210810172957.908475868@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@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 commit fa4a8dcfd51b911f101ebc461dfe22230b74dd64 upstream. The usb_add_gadget_udc will add a new gadget to the udc class driver list. Not calling usb_del_gadget_udc in error branch will result in residual gadget entry in the udc driver list. We fix it by calling usb_del_gadget_udc to clean it when error return. Fixes: 48ba02b2e2b1 ("usb: gadget: add udc driver for max3420") Acked-by: Felipe Balbi Signed-off-by: Zhang Qilong Link: https://lore.kernel.org/r/20210727073142.84666-1-zhangqilong3@huawei.com Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/udc/max3420_udc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) --- a/drivers/usb/gadget/udc/max3420_udc.c +++ b/drivers/usb/gadget/udc/max3420_udc.c @@ -1260,12 +1260,14 @@ static int max3420_probe(struct spi_devi err = devm_request_irq(&spi->dev, irq, max3420_irq_handler, 0, "max3420", udc); if (err < 0) - return err; + goto del_gadget; udc->thread_task = kthread_create(max3420_thread, udc, "max3420-thread"); - if (IS_ERR(udc->thread_task)) - return PTR_ERR(udc->thread_task); + if (IS_ERR(udc->thread_task)) { + err = PTR_ERR(udc->thread_task); + goto del_gadget; + } irq = of_irq_get_byname(spi->dev.of_node, "vbus"); if (irq <= 0) { /* no vbus irq implies self-powered design */ @@ -1285,10 +1287,14 @@ static int max3420_probe(struct spi_devi err = devm_request_irq(&spi->dev, irq, max3420_vbus_handler, 0, "vbus", udc); if (err < 0) - return err; + goto del_gadget; } return 0; + +del_gadget: + usb_del_gadget_udc(&udc->gadget); + return err; } static int max3420_remove(struct spi_device *spi)