Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3702440pxb; Mon, 24 Jan 2022 15:48:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxol/e6ACWJE14Z/XIcpr8VpTQjYPcUBpnNSqpyeI55NZt2hhihBGK3s1FD4lMTvayiF9yZ X-Received: by 2002:a17:90b:164a:: with SMTP id il10mr701970pjb.51.1643068114305; Mon, 24 Jan 2022 15:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643068114; cv=none; d=google.com; s=arc-20160816; b=O8+e6yHVlbO/b3ex2UUXXyEjVEB1srkR8LqEH8G5ele40Tbfz2NBVkdoKlRqjRD2SU gnnDxTUvUtyOAgbdUDzfnAuu3do79QqPIvlc358jQPKpL0KV9cBxZ/ZTlxjHQjvfUNOO ioRrUBBuyp+1BlliQ2suZIhIP+ROgVAa1EI0GljkjSFYncM2MwzBshX9mNZdVSSiltBt Ab4N+w08BzSrWMBM6TBKAK53PlTbFcVG7bKxdmVAyBd2cH8XhoXj5knnfJNv49QzKZKP Yrqz3NjvDv3cKqG/WLcDtva5dgSd02DxVxvsERHzdcUbbpckoKA0U8IgB7+6P5Orry12 DrsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7C1tCWvrZyBoMklzNT0LdbVe2DOaWSdmPk8xltyssiM=; b=WLLljzelyRimFnFvTbjbCb148LDqjIrDZmWk4SkXbmq9JMvLYiY5dSDzCnxWM/zWTK eBrl1Q8BSZmNHhO0eNYUAysN4pZVRk1hjUdp49/sqy6ttbvllog52QPfWmvsjGgLn0YL QIlduY6Dd+ix2OHHo7B8KVLxCibQczTnWgad6VE0nLCTp9dN9u8uGMbxsB+OCeTXpmfR v6o0lQazjQEyMTqHLEcMn2kPom55o2+/wZSx/mZ/waZI0NiJ09+YL4OJHi2K+lD5dr0V pRT9cnztrIriqItBHLSXH8OmwrutYeoQIkVio5Yrexk97Wfdh0bv4AHzZjeOppYw4wMM rLqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sTamqOwj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i14si15121602pgh.832.2022.01.24.15.48.22; Mon, 24 Jan 2022 15:48:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sTamqOwj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2362129AbiAXXln (ORCPT + 99 others); Mon, 24 Jan 2022 18:41:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1841135AbiAXW5l (ORCPT ); Mon, 24 Jan 2022 17:57:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 899FAC034610; Mon, 24 Jan 2022 13:12:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 45287B8123D; Mon, 24 Jan 2022 21:12:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93AE7C340E5; Mon, 24 Jan 2022 21:12:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643058742; bh=ZiUO++6bgchHIbgpfnE+8NHiJEyM/iEETegiv0Pg5dQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sTamqOwjrrZ3bLnheNVFcdpcCMysSASlZZaLOHc2WRB2pIn4oNFFJP0Y062bh5+iL EXM1cIBtz2MRTqMHbqLGPV0KhVDJfeYD1r6MFigy3RyOFbYFVC0NgQbSGX5pjcMQI/ UcRZrp36yQsrD2Z+hn42WVgjfhucsxbkboOqQMKY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Horatiu Vultur , Vladimir Oltean , "David S. Miller" , Sasha Levin Subject: [PATCH 5.16 0370/1039] net: dsa: fix incorrect function pointer check for MRP ring roles Date: Mon, 24 Jan 2022 19:35:59 +0100 Message-Id: <20220124184137.738106366@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vladimir Oltean [ Upstream commit ff91e1b68490b97c18c649b769618815eb945f11 ] The cross-chip notifier boilerplate code meant to check the presence of ds->ops->port_mrp_add_ring_role before calling it, but checked ds->ops->port_mrp_add instead, before calling ds->ops->port_mrp_add_ring_role. Therefore, a driver which implements one operation but not the other would trigger a NULL pointer dereference. There isn't any such driver in DSA yet, so there is no reason to backport the change. Issue found through code inspection. Cc: Horatiu Vultur Fixes: c595c4330da0 ("net: dsa: add MRP support") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/dsa/switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dsa/switch.c b/net/dsa/switch.c index bb155a16d4540..80816f7e1f996 100644 --- a/net/dsa/switch.c +++ b/net/dsa/switch.c @@ -675,7 +675,7 @@ static int dsa_switch_mrp_add_ring_role(struct dsa_switch *ds, struct dsa_notifier_mrp_ring_role_info *info) { - if (!ds->ops->port_mrp_add) + if (!ds->ops->port_mrp_add_ring_role) return -EOPNOTSUPP; if (ds->index == info->sw_index) @@ -689,7 +689,7 @@ static int dsa_switch_mrp_del_ring_role(struct dsa_switch *ds, struct dsa_notifier_mrp_ring_role_info *info) { - if (!ds->ops->port_mrp_del) + if (!ds->ops->port_mrp_del_ring_role) return -EOPNOTSUPP; if (ds->index == info->sw_index) -- 2.34.1