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 A88601C1AAA; Tue, 12 Aug 2025 19:04:36 +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=1755025476; cv=none; b=RSh5bWLmY2q6rqq9+hbaE4IElqiDIFYL26lLa+U6JaWCpCqdMvNtW0nwv1QY+thweCWoJ51BftBWIoyKn4jONIAHGQJniMYJAL4RYN/N/j1rwUahT363YNs03MTaavb9GnJ/EtrbTuZ5dD6Wj6oLfDodVMbd/qEWA/rGxmdDNVA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755025476; c=relaxed/simple; bh=yWgQ1P9ODKWErcF4Joz7F2gdhy5UHT+wJptZhLOKWco=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XgWxIV5MuO+0riecscq3/z+9xIvILFUI8cfWT0mS6xyy0MHD9UeeF1fqfUXcZRO7Ai8gpVaenDId74RIlHHbxs5IQQjjSbBYZ3JczvEDq25zcZx7Dop0W4sf6SgHgjjKktWG9wPyXY3cq7wh8k0L8tqFLNak3lyoOmRdXUEEUlA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nlnGNBq1; 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="nlnGNBq1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17E05C4CEF0; Tue, 12 Aug 2025 19:04:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1755025476; bh=yWgQ1P9ODKWErcF4Joz7F2gdhy5UHT+wJptZhLOKWco=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlnGNBq1Okdm/Bq9s99Dx3078qW6YGnYfPvdya3SjPMiNnF6yD8/aG1BtIdg/2Mws n4wzyT05xWLNjAbhf3TY91j9gjGJomzg6+OLNUSSIazD/8wLdon069n7WN0PVJpHr3 /sQOncE8fhClN4fT+8KlrJAJ2RDdczIs3cl8Tjf4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dmitry Baryshkov , Heikki Krogerus , Sasha Levin Subject: [PATCH 6.15 053/480] usb: typec: ucsi: yoga-c630: fix error and remove paths Date: Tue, 12 Aug 2025 19:44:21 +0200 Message-ID: <20250812174359.596660425@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250812174357.281828096@linuxfoundation.org> References: <20250812174357.281828096@linuxfoundation.org> User-Agent: quilt/0.68 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.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dmitry Baryshkov [ Upstream commit 168c3896f32e78e7b87f6aa9e85af36e47a9f96c ] Fix memory leak and call ucsi_destroy() from the driver's remove function and probe's error path in order to remove debugfs files and free the memory. Also call yoga_c630_ec_unregister_notify() in the probe's error path. Fixes: 2ea6d07efe53 ("usb: typec: ucsi: add Lenovo Yoga C630 glue driver") Signed-off-by: Dmitry Baryshkov Reviewed-by: Heikki Krogerus Link: https://lore.kernel.org/r/20250621-c630-ucsi-v1-1-a86de5e11361@oss.qualcomm.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/typec/ucsi/ucsi_yoga_c630.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c index d33e3f2dd1d8..47e8dd5b255b 100644 --- a/drivers/usb/typec/ucsi/ucsi_yoga_c630.c +++ b/drivers/usb/typec/ucsi/ucsi_yoga_c630.c @@ -133,17 +133,30 @@ static int yoga_c630_ucsi_probe(struct auxiliary_device *adev, ret = yoga_c630_ec_register_notify(ec, &uec->nb); if (ret) - return ret; + goto err_destroy; + + ret = ucsi_register(uec->ucsi); + if (ret) + goto err_unregister; + + return 0; - return ucsi_register(uec->ucsi); +err_unregister: + yoga_c630_ec_unregister_notify(uec->ec, &uec->nb); + +err_destroy: + ucsi_destroy(uec->ucsi); + + return ret; } static void yoga_c630_ucsi_remove(struct auxiliary_device *adev) { struct yoga_c630_ucsi *uec = auxiliary_get_drvdata(adev); - yoga_c630_ec_unregister_notify(uec->ec, &uec->nb); ucsi_unregister(uec->ucsi); + yoga_c630_ec_unregister_notify(uec->ec, &uec->nb); + ucsi_destroy(uec->ucsi); } static const struct auxiliary_device_id yoga_c630_ucsi_id_table[] = { -- 2.39.5