From nobody Fri Oct 2 11:44:13 2026 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.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 0495C361944 for ; Sat, 1 Aug 2026 11:09:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785582565; cv=none; b=LVnGP9pXuwk2TtxsPL6N45GNdoizr/yQ8QvlyyoB4fgXNr3DSaU/+BY/4cMQb1NVRdohGgF2tNT4uByeEGZBc8tXgpeUt7W1fZRIFrct1piKModrN8Bgt7grEFckLV36/DzuBwGmYcgQ7lI4HqU2MdceVpGf6wSyN+gfjwSuHEA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785582565; c=relaxed/simple; bh=lBYA02p+/O+qzH7dLpNk/39s6qEiCY5YCs0GlVPIZP4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZH1bcZ8RLlmdNmyfKB6oxMLP2cms2O4CZSjGztsnSYGvx7laeZAy5dbIYlnLSl0bO1bG513rWSYxKOFWRA3T/MjRzfZ8D8MjZEIhBpgClaXLOlxR1l7oqEjyGMwJ9kIVH+5jvmVvL4wm55w2fhhUI8wlUfB+K1wjhH+2Q70BYVI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cse.iitm.ac.in; spf=pass smtp.mailfrom=cse.iitm.ac.in; dkim=pass (2048-bit key) header.d=cse-iitm-ac-in.20251104.gappssmtp.com header.i=@cse-iitm-ac-in.20251104.gappssmtp.com header.b=tAb/xid0; arc=none smtp.client-ip=209.85.216.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=cse.iitm.ac.in Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cse.iitm.ac.in Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cse-iitm-ac-in.20251104.gappssmtp.com header.i=@cse-iitm-ac-in.20251104.gappssmtp.com header.b="tAb/xid0" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-38759bcd877so1720335a91.2 for ; Sat, 01 Aug 2026 04:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cse-iitm-ac-in.20251104.gappssmtp.com; s=20251104; t=1785582562; x=1786187362; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=ut+TYnUp65Th9//uFyyT2zkSxvallqu1/pfyahDUJyM=; b=tAb/xid0aLlB4Y/8TI1M9b1DuQDBsu2sb5WAVNhruwlthwtRA1nxDQC29pyiTP5kzC 9rnzRN1y/Pxp7nVsqV9yUbuS1Czbo3kJuIi0C2bMkCJWYBGdezp3h8xonRF594uWu7i2 qOTJahWmyFZfHUkrVS1UH4ceHcqcSX4U4kd8sj+pGWf0z44YwuMK0oDOV0MjrveUXBlq zjxnIYLUp0qkvPI5aBMKAqcPtFQ8O3HBCA97mB16H/p6udCKQBecvx/CjruYCCIvA9pq 3H/DTt0HknFB75LEVMjJWbynesnzFJt3UO62gDhA0KJtbRiWQvF8bbLJCCBIu87L5mZL aYhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785582562; x=1786187362; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=ut+TYnUp65Th9//uFyyT2zkSxvallqu1/pfyahDUJyM=; b=l5gptI2bn0oULn18Okl7LXTJnftxxsvlHIBKSdTlstwpmSqy5rVDncbpsxkP76n0B2 h4D6kQaPBMBWbjN/4nhO45WWOx7BZ6/DA+2YDbmkdrHJ0nuyybTgikpnIEKRbrSb899M JcBz3F91nAy6BuHrantwsANfJq2VBzXZOhjmqIIPwLay9/AgNyluPOrcQJwBsfIxppcG f1pcH5ZGAVpibLTImlgsITH7rd1bXD5U6SpvPhuVIIrRsXTzZW+ylSjUU6fvLNnxx8dI 12vHzX2yflNjl8eXZgREyiB74z6Q2H0JAtufSofrxnGHtFct0o9PpnUfQsn+RKTqT9LB yaEw== X-Forwarded-Encrypted: i=1; AHgh+Rq/E8I77cutadKV/6r91gmtC/xSoP1nO+IXHQwGhLNyaFRsGN7a+1EVxjYCrYWEI6M0aDHm+7NY829Waio=@vger.kernel.org X-Gm-Message-State: AOJu0Ywu4lIZRaUmeYdsVRC8p6Ufxb3qcnCb6RBbJZrS/jwkmUGFwkbi emg90OrSAADWQjWIULdRq5r2M2y8MOwkqYy9ACkbAF3cgTmLCmtDPWwLm5ey01m+Apg= X-Gm-Gg: AR+sD13T0rL3ljbgMwma5N0APuV1QnZXioU+hZ74Nt4WvEEdjmtciQJX9/OxEzVCO+D oyypt00X9LIElVPael8chxydKX+3MH1DFeoWmNRSJ0429QXUSYKbyZ0KXN1mkoFj9cg4d6a6GyX Nxna9F3Q5FroZJi/Q56qMgc2zv2B8SG1m/3hstQnB05L5EXpdPaVAkVf1KCGfeqGrPnORIYtei3 66nY80vcE9zqeedsXaHZjPm+U05AvZtQsPpDU+yMDJa3pc+cWDowsgxkLDhykCrgR9CZKa8N3dr 9PKdsmhDd0OA8L87Blt+jW0rN1BtMnYXlTYJstLeIgjFtOE0noqHCV1EebwRSXYJTKeA15zS17p uthvuzz778lOzVLTk14DQVTQ9ddKdgtyf2R82fASxbN1QWTf+sWN1fGxdkrLOViyP7U/B3jykNy uNC+iQAaamFQ9qP7Q6F/0UFV2wsQBly9ZW6ZOG/8zeJV2rdC/Aed+qxViejj7u1PX05UUg8xusu dzKjoCAAjXZJvQMHozfMgqFM2EHGWxetfow1lzzxImk46j6kdp38dyzeMK44B2dhxQKrZlha+g+ uEKgpmdJEpNjl9eAbsL4ElkNlw== X-Received: by 2002:a17:90b:53c5:b0:38e:85fb:71b9 with SMTP id 98e67ed59e1d1-38fbc3f9aa9mr3098165a91.4.1785582562113; Sat, 01 Aug 2026 04:09:22 -0700 (PDT) Received: from Metius.iitm.ac.in ([103.158.43.43]) by smtp.googlemail.com with ESMTPSA id a92af1059eb24-13fab4cb50dsm20596758c88.10.2026.08.01.04.09.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 01 Aug 2026 04:09:21 -0700 (PDT) From: Abdun Nihaal To: o-takashi@sakamocchi.jp Cc: Abdun Nihaal , linux1394-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v2] firewire: core: fix possible memory leak in build_tree() Date: Sat, 1 Aug 2026 16:39:13 +0530 Message-ID: <20260801110915.82561-1-nihaal@cse.iitm.ac.in> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The memory allocated for node in fw_node_create() is not freed when a parent port inconsistency error occurs. Fix that by invalidating references to the node, and then calling fw_node_put() on it. Fixes: 3038e353cfaf ("firewire: Add core firewire stack.") Cc: stable@vger.kernel.org Signed-off-by: Abdun Nihaal --- Compile tested only. Issue found using static analysis v1->v2: - Invalidate references to the node in the child nodes, as suggested by Takashi Sakamoto. - Use fw_node_put() instead of kfree() for consistency v1 link: https://lore.kernel.org/all/20260727095955.104972-1-nihaal@cse.iit= m.ac.in/ drivers/firewire/core-topology.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/firewire/core-topology.c b/drivers/firewire/core-topol= ogy.c index df2ac0dab106..3d0109c3ed90 100644 --- a/drivers/firewire/core-topology.c +++ b/drivers/firewire/core-topology.c @@ -227,6 +227,15 @@ static struct fw_node *build_tree(struct fw_card *card= , const u32 *sid, int self (enumerator.quadlet_count > 0 && parent_count !=3D 1)) { fw_err(card, "parent port inconsistency for node %d: " "parent_count=3D%d\n", phy_id, parent_count); + while (h !=3D &stack) { + child =3D fw_node(h); + for (i =3D 0; i < child->port_count; i++) { + if (child->ports[i] =3D=3D node) + child->ports[i] =3D NULL; + } + h =3D h->next; + } + fw_node_put(node); return NULL; } =20 --=20 2.43.0