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 71E23C148; Tue, 29 Apr 2025 17:48:00 +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=1745948880; cv=none; b=bRWp27FX88bOOz2nrKh658jdLJuK+XOgjV6Ev/qyO0xVIBHTlEePQW1sOjD6q+tTOyRN/sNL/6yzR4l6YdrOWMtt+cOfESn6D/v7HPsbDtoQ7e8zQeHk/QrDAWQeKfJmzmVyhoJhTfebxHlFIf6m/JbkJ5YOR7/AFLk2X+Nx0Mw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745948880; c=relaxed/simple; bh=cvloOVqpGmjYWr49SOAYwfVDBXbPCpVNAWRP4tJYLOA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fKaPeeQ9V4WjrgClIzO9YGKp1qMGQ+VgSPVY+BjSLX1V999IWXctFWHqvMvtNB4w+bd7/FJV4MZ1VbusJrmBlQfMQnFyiVBGzpU60VqAQQR/PLul25atJoqONuDxOvyzGtDPbQNXIYDGOB/KUq6sSyXm6l9M6lCrXh6PeNWq5Lk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rdexC1Jv; 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="rdexC1Jv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03062C4CEE3; Tue, 29 Apr 2025 17:47:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1745948880; bh=cvloOVqpGmjYWr49SOAYwfVDBXbPCpVNAWRP4tJYLOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rdexC1JvVPqzap4UgLy6hfqqiN90P6GpKJN8geVBYugLFJE4GQKNBa6k5cEaM3avU cCSOUHSE4K0v6vOIQmdP57/ALAWjwsVeMEU8syl+gISzvLz7DPN6xxmF59WS8R7DKK Sdyt8pHY3J3jD1IybdXXmeTAZz47v+3VwAlHsOUI= 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 5.15 148/373] net: dsa: mv88e6xxx: avoid unregistering devlink regions which were never registered Date: Tue, 29 Apr 2025 18:40:25 +0200 Message-ID: <20250429161129.246791558@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250429161123.119104857@linuxfoundation.org> References: <20250429161123.119104857@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-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 381068395c63b..e6d1801bb8f50 100644 --- a/drivers/net/dsa/mv88e6xxx/devlink.c +++ b/drivers/net/dsa/mv88e6xxx/devlink.c @@ -653,7 +653,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