Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2736751pxj; Mon, 31 May 2021 09:27:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy1RRNdTaYOS/sHp8T/sd+nbI6/MWhN8dYizWx2HqUzx0+K1bJstOtAvAqPhUF8mFVgvUQn X-Received: by 2002:aa7:da94:: with SMTP id q20mr25332374eds.316.1622478443812; Mon, 31 May 2021 09:27:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622478443; cv=none; d=google.com; s=arc-20160816; b=zkdbcQi23c86rzIWIXh1KZ1fq9fGfW+SUfOOy4tYLAU2TpO/wg+oZt8ynCwztZlbNd mn/IwQh3+m3vb5yOBgb/W0wZ+1wQpshN+HwjIzRUCwPSOyeWRwa+a6Q/YVLp8rEnS+Oj TcwyUntvNPVALHdWvHTRRt4gM0nett/Bm3TXk+13nTMMRbPDhCNCzKG2QnAP2k7g+UHa hzDd2o7rlP1Jr+k7V19vjuRMqZfuLghjTHCwON7yQnRd/8dPQ0WjMaZpOG/Zdgq7pW32 TzXAM0uQwUh8TJk7E9pz3HVgfARyN1Rw5d2Dui5BxOxoawa+YaN+JHxpAJWm9ly+AZb5 zVuA== 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=XDssxGW3go+24++lScp9Q+nZrT/KoBVnhgce/blejCI=; b=cFaqSvOt8UGqItl3CBOZx8G6CQvK3EeiU321TQWEscZvX9+SmqWM1M3tngnzwQG1Lb c9yVad9uSA2mRVO3goMaeIy+r4bxZr6HfufewhPtp+EFZm80IM0sY/HBvnkP2IR2J5n/ w3IbLLhTA5BOZmg8j71i/rg+O+xY7JB+trbZ7CaSvsdMoLna30zL6MhKNgSD7X33AFH3 AYMW98xtODtFR3IroJkGOCoUAtRKIwS1y03WSEh0eKxeSfqeTjhdi/mvorBdjOUrhBze lgMmGFJfLoqQ01KDZWxrNvuu/iy8Ygh0kE/LFmfw+/9aA8tZkDS/XEqw7YjFCCEvbGD3 aQgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BUvLyvii; 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 l18si13958670edt.366.2021.05.31.09.27.00; Mon, 31 May 2021 09:27:23 -0700 (PDT) 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=BUvLyvii; 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 S233399AbhEaQ1l (ORCPT + 99 others); Mon, 31 May 2021 12:27:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:40312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234227AbhEaOpJ (ORCPT ); Mon, 31 May 2021 10:45:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 25FEE61C84; Mon, 31 May 2021 13:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469302; bh=U7ubMBqioOt7j6nprRGfQT/T68oUMEcDQugGFGj0zs0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BUvLyviiAyROsAR7tkIt0b9WVyiJbzIf9hgikaVt9ZdJZHUOpxfUoQqN5FWCPQuOL 3DHr8ibRVPsrEDJNdU0N90ZqnobwmdNvnaROLDKpfk+GjEjtMBAMUl6YPdY6GnORGV qdL4bk4lDumtrr6WHbEhZgj5Hk/3ctBKKy8zgET8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vladimir Oltean , "David S. Miller" Subject: [PATCH 5.12 147/296] net: dsa: sja1105: call dsa_unregister_switch when allocating memory fails Date: Mon, 31 May 2021 15:13:22 +0200 Message-Id: <20210531130708.811823022@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@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 commit dc596e3fe63f88e3d1e509f64e7f761cd4135538 upstream. Unlike other drivers which pretty much end their .probe() execution with dsa_register_switch(), the sja1105 does some extra stuff. When that fails with -ENOMEM, the driver is quick to return that, forgetting to call dsa_unregister_switch(). Not critical, but a bug nonetheless. Fixes: 4d7525085a9b ("net: dsa: sja1105: offload the Credit-Based Shaper qdisc") Fixes: a68578c20a96 ("net: dsa: Make deferred_xmit private to sja1105") Signed-off-by: Vladimir Oltean Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/dsa/sja1105/sja1105_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) --- a/drivers/net/dsa/sja1105/sja1105_main.c +++ b/drivers/net/dsa/sja1105/sja1105_main.c @@ -3683,8 +3683,10 @@ static int sja1105_probe(struct spi_devi priv->cbs = devm_kcalloc(dev, priv->info->num_cbs_shapers, sizeof(struct sja1105_cbs_entry), GFP_KERNEL); - if (!priv->cbs) - return -ENOMEM; + if (!priv->cbs) { + rc = -ENOMEM; + goto out_unregister_switch; + } } /* Connections between dsa_port and sja1105_port */ @@ -3709,7 +3711,7 @@ static int sja1105_probe(struct spi_devi dev_err(ds->dev, "failed to create deferred xmit thread: %d\n", rc); - goto out; + goto out_destroy_workers; } skb_queue_head_init(&sp->xmit_queue); sp->xmit_tpid = ETH_P_SJA1105; @@ -3719,7 +3721,8 @@ static int sja1105_probe(struct spi_devi } return 0; -out: + +out_destroy_workers: while (port-- > 0) { struct sja1105_port *sp = &priv->ports[port]; @@ -3728,6 +3731,10 @@ out: kthread_destroy_worker(sp->xmit_worker); } + +out_unregister_switch: + dsa_unregister_switch(ds); + return rc; }