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 61524281356; Wed, 23 Apr 2025 14:57:19 +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=1745420239; cv=none; b=KqRH6bu4gahhrph5he3dvYPpXjvNDxwMKHql1GiDSydsDV55hsKkP2J5V2+th3Nk24w3okIZqGOx1bc20KjnpodOGtL2iccDqQzWhE2EipTQy69bhjiZBOeGs91Fzb91HPDenH4jZy3ygCMei9HI93kiF4QT+u/8wTTGRUMPn00= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745420239; c=relaxed/simple; bh=xKWFHoNEldK2GRtWW50ciMXlwmPaN5Z0KejPbVeXlxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N5rkzNqhBUFaFT8tJAM75ufUNZMHnx+4VrhjtyE0LmagvYu5RqmSK58wx6/q3GcDSJDTcYoUM/pPVRi6LkVLvwzHTkfz1dFY0jRcBx1jkQNFZeKrHHEw7S1LfuZQOhBEDPoV4laeIKq1JNpG0TawpfPdUEhr2tJ2z8IPgVgoP2A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Rv3pW7rJ; 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="Rv3pW7rJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E863BC4CEE8; Wed, 23 Apr 2025 14:57:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745420239; bh=xKWFHoNEldK2GRtWW50ciMXlwmPaN5Z0KejPbVeXlxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rv3pW7rJCgD6zphRqbyZyfa7d4SSD5o3pEoxz1oauWXFmVrSaQPcXpJfeCJHFfVfI jfxSNDFeztk8TX+nhB1USmrjIkwe64OwB4QnXVnBao354ZxD/DK9QkIzJ1pbpVgJoQ yu1LSRF4igvH5sSVsPevWBX2jT2ygbdqOc7K4eKg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Russell King (Oracle)" , Vladimir Oltean , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.14 074/241] net: dsa: mv88e6xxx: avoid unregistering devlink regions which were never registered Date: Wed, 23 Apr 2025 16:42:18 +0200 Message-ID: <20250423142623.619218696@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250423142620.525425242@linuxfoundation.org> References: <20250423142620.525425242@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.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vladimir Oltean [ Upstream commit c84f6ce918a9e6f4996597cbc62536bbf2247c96 ] Russell King reports that a system with mv88e6xxx dereferences a NULL pointer when unbinding this driver: https://lore.kernel.org/netdev/Z_lRkMlTJ1KQ0kVX@shell.armlinux.org.uk/ The crash seems to be in devlink_region_destroy(), which is not NULL tolerant but is given a NULL devlink global region pointer. At least on some chips, some devlink regions are conditionally registered since the blamed commit, see mv88e6xxx_setup_devlink_regions_global(): if (cond && !cond(chip)) continue; These are MV88E6XXX_REGION_STU and MV88E6XXX_REGION_PVT. If the chip does not have an STU or PVT, it should crash like this. To fix the issue, avoid unregistering those regions which are NULL, i.e. were skipped at mv88e6xxx_setup_devlink_regions_global() time. Fixes: 836021a2d0e0 ("net: dsa: mv88e6xxx: Export cross-chip PVT as devlink region") Tested-by: Russell King (Oracle) Signed-off-by: Vladimir Oltean Link: https://patch.msgid.link/20250414212850.2953957-1-vladimir.oltean@nxp.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/dsa/mv88e6xxx/devlink.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/mv88e6xxx/devlink.c b/drivers/net/dsa/mv88e6xxx/devlink.c index 795c8df7b6a74..195460a0a0d41 100644 --- a/drivers/net/dsa/mv88e6xxx/devlink.c +++ b/drivers/net/dsa/mv88e6xxx/devlink.c @@ -736,7 +736,8 @@ void mv88e6xxx_teardown_devlink_regions_global(struct dsa_switch *ds) int i; for (i = 0; i < ARRAY_SIZE(mv88e6xxx_regions); i++) - dsa_devlink_region_destroy(chip->regions[i]); + if (chip->regions[i]) + dsa_devlink_region_destroy(chip->regions[i]); } void mv88e6xxx_teardown_devlink_regions_port(struct dsa_switch *ds, int port) -- 2.39.5