From patchwork Mon Oct 21 20:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13844661 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ABF9A1FDFBE; Mon, 21 Oct 2024 20:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729543537; cv=none; b=h8R+S05TQf/rljhCx6I6zsdv6BLcpWWhbSRLiVmiLJzBjvLutlkVKYDbaisey7Xnp9ktdxsPfbDOfeo1TjFR9lWWrBHjFo2nz4QRlWafyAtJbxhXESE453KQqqNd2vNGLfA7Kq27+HUHusDmmI3VsFYnPF/9Ru+g5OzCz+Ml9hM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729543537; c=relaxed/simple; bh=w6NXKVIyw1kaqdbze/Lw/u07zmd53GQIC2q0s88hSRQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FHFunQmsKXxEwCU8YnPs5ltoCosEjdtHOzMc20U/W5yWGSsz0vaSyEYvgkVtMaa5/F8Xj+VKvH4Y3DOQ6S+I3XqPsnf1f/aPcnd5zvjz1bf7/fpDWABORMhgLXm5piYj+y+cWyzsmAjT4Aw+P0auQXiUw15zoup1d0MK9Sf5CJE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RE6XsPvx; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RE6XsPvx" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-37d63a79bb6so3796969f8f.0; Mon, 21 Oct 2024 13:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729543534; x=1730148334; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=HDRboVblVc9uDKv6XTsqY/eORK+gbYPrarQMQD9pPX0=; b=RE6XsPvx8GE8KbjxPOeOyR5MUKNRMvaofTEYtjQV6c+Yjwpj0UTnKAMVIi8SCmi+3J ibrTegcEWXXIC6gwMeK9wytvk1Nsseo62KdYD0G0ijxJQDlIkbqyiYbLNbTxwjXuBJ0z jI2/XP3Prn3/+UdnGP0OSWQHoYVXeMhtMBdq0XFDSiDPD/u+0aGz8yXHf4joEUXKvXgz Kzri/ksfX8I2reQa+birMPrVXQaG6PuYCcOFlMMYSxdN29yU+blpL4NyZeG5cj8LGJ/U 8vb62NP2+UgumKmmcWlUOIF26oiHeQmtxffGBpUkfx/gmi9zg+BaG6/qwrrmmRi7ZALm R8Cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729543534; x=1730148334; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HDRboVblVc9uDKv6XTsqY/eORK+gbYPrarQMQD9pPX0=; b=f41nxRGzmwBa+MyoiEP+7zIMUG0HK97VSSPM/142gNdr7vNZ736G+89FPr4MP33jrb +7yrxKVmH3y77+6a4z7n3AaaqFKxPmZO0e+uwgWDnpcIzoX75B3ZGtFjQqrugwaetITm 6fAtMzrc+Ery+kVHSF6zQO51DuFl2lzr36tKtp813YX8ISIgXpM/IeetizAWhXMFOD1z SJAmFL6sQRA3rv3Oe60ZHUYuVuVq+QdU8Ids+hLf2YoOPs18Y68qftFlTXoZi0ctGzWG uaIKRwO6oEihyUGBMWQoCFhw14cz85Gh2+XJJlP5bDuE2N7ya57eoZuE9J83Tw8sQpVI s7Zg== X-Forwarded-Encrypted: i=1; AJvYcCUmK8S4VAn7ri4CymKvJGcWNgth0jtVZ0HIYxKhPc5kmizEv6M7bdaQBl9R7sjjE1KdOCT1EIzR@vger.kernel.org, AJvYcCWZO4lbZyLskp02uUIO7ZV8OHcz9wakNn6sP7hzCL/dH3hFtWFI3lUk6TQD3eVI7wJEWZjt/IDy0ufqd/c=@vger.kernel.org X-Gm-Message-State: AOJu0YzgyOwdBl3PV4HZWJTKAGuB7/6TB0uqNer+UJ7Y1r4NbL4Gp4DV YsGLtIuyPELG431im8Id5HFRRBki7/UlvkZCnIeYmk1Dz0Jx17in X-Google-Smtp-Source: AGHT+IFXTcx40MryoSH/3xskgQ7Lce/y/OnjX7UHaTibP6PFRUsy5zHpRuQsaSUYcbN81rgc5Vx+jg== X-Received: by 2002:adf:ed11:0:b0:37d:3171:f2d4 with SMTP id ffacd0b85a97d-37ef21ac857mr274946f8f.43.1729543533770; Mon, 21 Oct 2024 13:45:33 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-023d-d91a-ee8e-da73.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:23d:d91a:ee8e:da73]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f570d49sm68483595e9.7.2024.10.21.13.45.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 13:45:32 -0700 (PDT) From: Javier Carrasco Date: Mon, 21 Oct 2024 22:45:29 +0200 Subject: [PATCH v2 1/2] usb: typec: fix unreleased fwnode_handle in typec_port_register_altmodes() Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-typec-class-fwnode_handle_put-v2-1-3281225d3d27@gmail.com> References: <20241021-typec-class-fwnode_handle_put-v2-0-3281225d3d27@gmail.com> In-Reply-To: <20241021-typec-class-fwnode_handle_put-v2-0-3281225d3d27@gmail.com> To: Heikki Krogerus , Greg Kroah-Hartman , Hans de Goede Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco , stable@vger.kernel.org X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729543530; l=922; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=w6NXKVIyw1kaqdbze/Lw/u07zmd53GQIC2q0s88hSRQ=; b=ATavkCxMukaDJQDmwHcwdCrGyIWNzqq++O7wiM0KgtNUCKpGmJ088AoTiFy5RjY5Pix/hFFnr uwOfoMumcbLBGn/t97YPYvN1KzV/kmsuGDd28QKSeTXiWr0Mpijb1WS X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= The 'altmodes_node' fwnode_handle is never released after it is no longer required, which leaks the resource. Add the required call to fwnode_handle_put() when 'altmodes_node' is no longer required. Cc: stable@vger.kernel.org Fixes: 7b458a4c5d73 ("usb: typec: Add typec_port_register_altmodes()") Reviewed-by: Heikki Krogerus Signed-off-by: Javier Carrasco --- drivers/usb/typec/class.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index d61b4c74648d..1eb240604cf6 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -2341,6 +2341,7 @@ void typec_port_register_altmodes(struct typec_port *port, altmodes[index] = alt; index++; } + fwnode_handle_put(altmodes_node); } EXPORT_SYMBOL_GPL(typec_port_register_altmodes); From patchwork Mon Oct 21 20:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13844662 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B61A11FE102; Mon, 21 Oct 2024 20:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729543538; cv=none; b=SNe+gsCgeS5rQv+dnFqsObjNJNGtZBgE/0QLAzCSpogam74Fu9RUeTq3PtR/T/ebEfQZGgr8f7bbnrwPOmD/KXQZdl9q4y4viT7iw5IfQh0eq8+FyuxDCeKI13cNOCdYadmz8wOUlnOo6Rzmudo81BsROw6pnIBxo497w4/UunY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729543538; c=relaxed/simple; bh=iTXPCyWFfmoke+EkEyW3CprjV9dJ+3h0SeLO2+RWcQk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pfkOKIPTUdLr0K74ngYKR+lPXjtzVa13n87n5njinuuOU6dmeSeOCZVBhkXhWeMt4ENqdmbP7HZ0JbarTRvfmHrMTqngYeiQAjOgYLJDH88T4buxybBT0cmyHY62Il/7iP7eNmbxsQIhE5Kdu38relclXdakzHG0m01xWpSZ8ew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DY1J2Hh4; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DY1J2Hh4" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-37d4ba20075so3705514f8f.0; Mon, 21 Oct 2024 13:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729543535; x=1730148335; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=DpdXzACTR17oC9mvPl+no2YAXtwyLIf8vYi2lEtxjm8=; b=DY1J2Hh45uYoVdx5ASgyqiyDtctITeON8ofTmaMIEdbNG4s7o0kqG7Zj59lK5ze2uS iQeXLbt2dUl4VAsNy2FURfdEWGsCnDdRltzXRFwQFzFbQvlAVI89S4TnmeBne2xZdZYz ZlSfdmM0YVdBBvLtngS0qeba3NFbcnb9/4+RiqLji4OVoogPAzOD1l09923mWBUZcNnJ 1Y0DQ0bdNg172dGt2jvb3b8Skn3eopDB63tGCKT/okEXoRGbTzhgUzt8XQOKuPDubuLs Yz+oIqW1R9/n8qx4+kwxMGKpbF58clsLdpARWmzO8YEjZwRw79IMX2S9pfDVkAlzpncu tcPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729543535; x=1730148335; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DpdXzACTR17oC9mvPl+no2YAXtwyLIf8vYi2lEtxjm8=; b=TK2lNYaR49psOzeZUljUGQ3TdtYsR4a4S6Q23RQK+ln45tqvWibyHZITsJGoxXoxg4 s/Tzf/8Hg3vA1gfnN8Tdvp0eW+fe6cXp4X9KvQiWoE5bOB7bqg3GpYyhGM9F2cl1SHtt LKiY8krRfGQFs59ecEv12Bq9lGnLGrjAGumyDN8rPcNRTYLYTmHk3Fd1wzIE9ydDmAjb AXTrpc/Kd8xn3O3ns9BuoG1b8AZFFUzaFSAGIEZobXrmbPGntpCrKqQyrTTOuarTA3ek q7MJnE9zOD+1hd12wkbte7BmVapZaOtOqJ595eDNAjtJlGi+hbKeBAwZsdGL8V++7JeX 6Xxw== X-Forwarded-Encrypted: i=1; AJvYcCVII1tTn4oU0NCfAMnLIOS5rax4F+f1vzZQO/iv3oyLoF0plN/+OxgClzvv79z3/uA5VFIVaoW+q+rB0Xo=@vger.kernel.org X-Gm-Message-State: AOJu0Yxr6oUbWDZMDnbnTdQMYrINk1A9RbaiNYLIAgMEAvwqFW6WAm8I +kEUy3af8pZk7D6yGZsctc3whDhQjdEwqR6S9HCCOZz3jkGWP7MQ X-Google-Smtp-Source: AGHT+IHuT8jIBdZKU/lv4lfBzj0LIVHwyfbxTqe+kHoRyct1ap2UERudBKTCQoiXs/PF3g+j0BQwhg== X-Received: by 2002:a5d:65d1:0:b0:374:c31e:9721 with SMTP id ffacd0b85a97d-37ef21ac237mr260994f8f.42.1729543535066; Mon, 21 Oct 2024 13:45:35 -0700 (PDT) Received: from [127.0.1.1] (2a02-8389-41cf-e200-023d-d91a-ee8e-da73.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:23d:d91a:ee8e:da73]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4316f570d49sm68483595e9.7.2024.10.21.13.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Oct 2024 13:45:34 -0700 (PDT) From: Javier Carrasco Date: Mon, 21 Oct 2024 22:45:30 +0200 Subject: [PATCH v2 2/2] usb: typec: use cleanup facility for 'altmodes_node' Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20241021-typec-class-fwnode_handle_put-v2-2-3281225d3d27@gmail.com> References: <20241021-typec-class-fwnode_handle_put-v2-0-3281225d3d27@gmail.com> In-Reply-To: <20241021-typec-class-fwnode_handle_put-v2-0-3281225d3d27@gmail.com> To: Heikki Krogerus , Greg Kroah-Hartman , Hans de Goede Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.14-dev X-Developer-Signature: v=1; a=ed25519-sha256; t=1729543530; l=1533; i=javier.carrasco.cruz@gmail.com; s=20240312; h=from:subject:message-id; bh=iTXPCyWFfmoke+EkEyW3CprjV9dJ+3h0SeLO2+RWcQk=; b=VvYpFUZr4WOebnc7GA3xBxR7tcFnJu6NHAn8PNrNRIQONC4BNBRQ8jiahMSokmkjwjUmi7RWn 0a193ROFi8hC7Pohmovn0DGx+V4KRAJd5WPb3486MwsI4lsF7TmPJjO X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=lzSIvIzMz0JhJrzLXI0HAdPwsNPSSmEn6RbS+PTS9aQ= Use the __free() macro for 'altmodes_node' to automatically release the node when it goes out of scope, removing the need for explicit calls to fwnode_handle_put(). Suggested-by: Heikki Krogerus Signed-off-by: Javier Carrasco Reviewed-by: Heikki Krogerus --- drivers/usb/typec/class.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/typec/class.c b/drivers/usb/typec/class.c index 1eb240604cf6..58f40156de56 100644 --- a/drivers/usb/typec/class.c +++ b/drivers/usb/typec/class.c @@ -2293,7 +2293,7 @@ void typec_port_register_altmodes(struct typec_port *port, const struct typec_altmode_ops *ops, void *drvdata, struct typec_altmode **altmodes, size_t n) { - struct fwnode_handle *altmodes_node, *child; + struct fwnode_handle *child; struct typec_altmode_desc desc; struct typec_altmode *alt; size_t index = 0; @@ -2301,7 +2301,9 @@ void typec_port_register_altmodes(struct typec_port *port, u32 vdo; int ret; - altmodes_node = device_get_named_child_node(&port->dev, "altmodes"); + struct fwnode_handle *altmodes_node __free(fwnode_handle) = + device_get_named_child_node(&port->dev, "altmodes"); + if (!altmodes_node) return; /* No altmodes specified */ @@ -2341,7 +2343,6 @@ void typec_port_register_altmodes(struct typec_port *port, altmodes[index] = alt; index++; } - fwnode_handle_put(altmodes_node); } EXPORT_SYMBOL_GPL(typec_port_register_altmodes);