From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CFCC03537FC; Wed, 8 Apr 2026 18:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672270; cv=none; b=TIQSK7tDqGutqk0yausmoiUpq/VHbl2Oue3IBv3kFmmdYwqGx1k9k+ynJ7b0pykSnQNJNebxMDUQL9sZiGmakBKy6pBdYS2X/owUR0NIwuTEuTtV9NAqke4f8palSVRwTUMKKTmJj//OOc1jlmNhYi/FBTC0ARCr+PTvoFRLHps= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775672270; c=relaxed/simple; bh=XsiJ8vOaSjyJqF679fkw/MPKtzT4H71QYZ5mD/mseP8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F4eV+2HQyy836i2TBGzE7+4DKglDqeZz+7HrnG/xFZYnrGDmep7ahXxWAtNexLE8z3id124gtf3JPjcp/8DmUypG7lz5bpmUR1dGTluqpxF4dN9Be34QRvjr3BXw9XO/f5E4gbEbgQDWIF8PD1KLd0QjffBraiav0coLuZAnqEA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Pvodc9Gn; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="Pvodc9Gn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66601C19421; Wed, 8 Apr 2026 18:17:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1775672270; bh=XsiJ8vOaSjyJqF679fkw/MPKtzT4H71QYZ5mD/mseP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Pvodc9GnN9jVFevuZr5xHzZKP06y/DeOkj73WLZHJeLIBFGuj3e0FxRZPN3VgLG6Q F/ITNriKlKbtsQ7w5RFFPgVr8wPpENHuiST1jINZMsdaCRFbQA6goDrcbVpBn82lEJ DBHPVoaiVeFzdm8TYd6NzPuRnoZpAIQe0Nhfdb1I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, stable , Guangshuo Li , Heikki Krogerus Subject: [PATCH 6.1 228/312] usb: ulpi: fix double free in ulpi_register_interface() error path Date: Wed, 8 Apr 2026 20:02:25 +0200 Message-ID: <20260408175942.271353036@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260408175933.715315542@linuxfoundation.org> References: <20260408175933.715315542@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li commit 01af542392b5d41fd659d487015a71f627accce3 upstream. When device_register() fails, ulpi_register() calls put_device() on ulpi->dev. The device release callback ulpi_dev_release() drops the OF node reference and frees ulpi, but the current error path in ulpi_register_interface() then calls kfree(ulpi) again, causing a double free. Let put_device() handle the cleanup through ulpi_dev_release() and avoid freeing ulpi again in ulpi_register_interface(). Fixes: 289fcff4bcdb1 ("usb: add bus type for USB ULPI") Cc: stable Signed-off-by: Guangshuo Li Reviewed-by: Heikki Krogerus Link: https://patch.msgid.link/20260401025142.1398996-1-lgs201920130244@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/usb/common/ulpi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -331,10 +331,9 @@ struct ulpi *ulpi_register_interface(str ulpi->ops = ops; ret = ulpi_register(dev, ulpi); - if (ret) { - kfree(ulpi); + if (ret) return ERR_PTR(ret); - } + return ulpi; }