Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2666334pxj; Mon, 31 May 2021 07:47:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt/UWfYtVsT93s/zuGH0NlumkxB4myDtPU+lgIibEjgvdiiA33UPK6KSobxH05RQbrKPiS X-Received: by 2002:a05:6402:4389:: with SMTP id o9mr25622201edc.368.1622472464483; Mon, 31 May 2021 07:47:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472464; cv=none; d=google.com; s=arc-20160816; b=fxtnmwGF+eIkoFJc5UUjsNLnCoqt9GsPQKzC3jJZ5IvhGuGTftusqCH7Gf5/7dYzMC 5sOMipSHODhzhbf8/8nk7ZSZEDexnGjcQ4tQND9XboF4qVcN8yxjozS/LU9gDNd0ZA3F Ktq6iQ0s672zAofETQzUWIRAahaDipKNbutXo530kzvk3pitDY02udQZKoecOidsPQng rbzRx68z/hn98YQ3reFuFvl/hdfHl1dPRLHHmiQQbs7tLD6r4ZGDK7jWpU2EJpIaU+8H PHBiG03RmMD8iHTGKbo0wNbX1xUlSSJ6IYeKguAGG4Iqk0fbaWYqTl7cGmBtuxDAyzgD 0Upg== 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=3kwUx0lt35t3gKFgFL8nAwjtUf1ZVJRa2Sr2sVtBkvY=; b=F0dsygs3wZiG1NahDgBNEhhiivaKOGn/PgfIPqhXDeYzdgpwkuTKenORb89MnCOXMp W1W09beRDtx+INhYzmbhSwqPmbKSlnuXFxaPlvy+9O4vY97uHLEBQoYbVRcC2qHfzt4v khT7d7uM6s8wtu5Kls4309BiDClAd4zO8jvFMgrliiVRg1R5Uq+S7lkSJeJcd2DsCBuT 9UakCC6W0+43n89GnMEXk18v53HozZ5dF2dJ7HzAUt5nBAacDY3CCFixy5+C+co9yX1v RqPptLY/Oib4ggGT1lZa7G3LQ7JrAASOpuUYz3RRGMoTBvjfzp3kNrSZMiqWmyTog0ee OIdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=keFXejyV; 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 u10si12841379ejh.112.2021.05.31.07.47.21; Mon, 31 May 2021 07:47:44 -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=keFXejyV; 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 S231585AbhEaOrs (ORCPT + 99 others); Mon, 31 May 2021 10:47:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:32910 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232698AbhEaOAx (ORCPT ); Mon, 31 May 2021 10:00:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1741961462; Mon, 31 May 2021 13:36:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468196; bh=i/yh22XRqMBDWXKWA7tVRwpyvyI939/Wesu5tWdN0YY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=keFXejyVnhnuGN8eV858yQc5/uWpLEY8mv5kmCSazNAIm1FElJLBfE8Yp57l+ozeI 5qfqtT4on608rSINSP2nFgueHEzo4QorEq6b/CQPFCzEfrq2QwmoOTy5Oi5yI+OKZL BA2T7h+geQDIK2/kRvt7xR27SQfvm8VJ/uXPaj8M= 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.10 118/252] net: dsa: sja1105: call dsa_unregister_switch when allocating memory fails Date: Mon, 31 May 2021 15:13:03 +0200 Message-Id: <20210531130701.994650447@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 @@ -3483,8 +3483,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 */ @@ -3509,7 +3511,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; @@ -3519,7 +3521,8 @@ static int sja1105_probe(struct spi_devi } return 0; -out: + +out_destroy_workers: while (port-- > 0) { struct sja1105_port *sp = &priv->ports[port]; @@ -3528,6 +3531,10 @@ out: kthread_destroy_worker(sp->xmit_worker); } + +out_unregister_switch: + dsa_unregister_switch(ds); + return rc; }