Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3425683pxf; Mon, 29 Mar 2021 01:44:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwskY5fy5pVUojPsxcBnx9UncRMxth0XE1JK3L+p2JCE5moog759nSLu/vHfXHBPpJRNZVe X-Received: by 2002:a17:907:75fc:: with SMTP id jz28mr27642620ejc.490.1617007441941; Mon, 29 Mar 2021 01:44:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007441; cv=none; d=google.com; s=arc-20160816; b=wWGCpGOhWP/+i5NqwRe7OttdbKq9Te+87LbVHjAeIGcznheK6DoEt5N1voG0jLGena TWLmhmVi6wLvjqsO0UiFVkc18WY82CUYunwjklsgi4AvwLyscj4URvGTL/rgCxS2Fch+ XsJJCzfjnYayT6rQmag9XPaPd+X8d0SMHjTBO9d4G+HKOdqqMZ1IIuk5daszH9aSbpNK AMtpTCind6+vuGTm7GpXQ/NBQ4Agp3+aEg4KYKzkg9zkIGq43wiBrQRrYxYtpK4iH3Zr tJuvp+A8Vl7WHXRBuvu5NmCxmMmuURQZKM1iCq8/1NVljvwN+nYFkTY3DioyNnCH5BXw 099w== 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=4/R8G3QwHTxK9Ks5kQ0YO+brLToTZSkR8UgGl4DRjko=; b=03DvZCiNA9X1WMlfjfSTxUreJmaeKIQm/r0rrh0cunegRD9t27Difm6aIssjjzIhVj 7Y7pBdMxTDCzUjDumoc6YeoQo7L4jgcjEvjNgGES9p74kfDwP1TLqpRkn+6cAEnLy3tN qDTB+7uxhJ1Zss1apEoqHRv5Uez++ChP4so9FapY9byQiJx6W7s+fByUGoPNmj7aDaov mSj+47Sx1okQyrIhJGhbTUT3Pd9DT+Zbt088D/8OpFWtJW4mXBrGfCTsggl4pWSWk5qY CtXf7Lu1+nK6ZdIPOW9i6bzUwEd8BVrvLRNFjE4Qn5NPK/Lv2EQyayhddwURLm+GCH7x i5PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bJVgquiv; 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 bv9si12093301ejb.377.2021.03.29.01.43.38; Mon, 29 Mar 2021 01:44:01 -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=bJVgquiv; 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 S234953AbhC2Il3 (ORCPT + 99 others); Mon, 29 Mar 2021 04:41:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:57602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233401AbhC2IRn (ORCPT ); Mon, 29 Mar 2021 04:17:43 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DD34361878; Mon, 29 Mar 2021 08:17:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617005863; bh=JKy01XnkOhs0NojHS5kfHMLe1XdiJ4ykRPzETY1oIzk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bJVgquiv/izMuYfExs0pO4BNE2aNI3xK385KkMkt3QGdIBN15u5I39/eClYJavcvy 1jr70/wcbxFud+lXMy17FyR1hW3LpgakioRU/5LPRS60b+1n5RhsDmvyZY18xI6fYP xvbs2yjpZiR0N/D3a1v2+Sm0dHso4aDQ7jtnuvog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, TOTE Robot , Jia-Ju Bai , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 025/221] net: wan: fix error return code of uhdlc_init() Date: Mon, 29 Mar 2021 09:55:56 +0200 Message-Id: <20210329075630.018742705@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Jia-Ju Bai [ Upstream commit 62765d39553cfd1ad340124fe1e280450e8c89e2 ] When priv->rx_skbuff or priv->tx_skbuff is NULL, no error return code of uhdlc_init() is assigned. To fix this bug, ret is assigned with -ENOMEM in these cases. Reported-by: TOTE Robot Signed-off-by: Jia-Ju Bai Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/wan/fsl_ucc_hdlc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index dca97cd7c4e7..7eac6a3e1cde 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c @@ -204,14 +204,18 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) priv->rx_skbuff = kcalloc(priv->rx_ring_size, sizeof(*priv->rx_skbuff), GFP_KERNEL); - if (!priv->rx_skbuff) + if (!priv->rx_skbuff) { + ret = -ENOMEM; goto free_ucc_pram; + } priv->tx_skbuff = kcalloc(priv->tx_ring_size, sizeof(*priv->tx_skbuff), GFP_KERNEL); - if (!priv->tx_skbuff) + if (!priv->tx_skbuff) { + ret = -ENOMEM; goto free_rx_skbuff; + } priv->skb_curtx = 0; priv->skb_dirtytx = 0; -- 2.30.1