Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2476716pxj; Mon, 10 May 2021 04:03:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb5SIJ5d1PK6/YxB+xXhIKhO5hJz+eFGAJ3rFs8jaZkCwbukB1sD3vFpo8RHvbkAxEuy+a X-Received: by 2002:a92:c20e:: with SMTP id j14mr8442276ilo.259.1620644594654; Mon, 10 May 2021 04:03:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644594; cv=none; d=google.com; s=arc-20160816; b=NXr1RpeBhZ3SLpklOBM8D941qdSCWjydDlm+lJ6t6BejmxGYaB/t/JoYbZ8Dbv+HPe vePcFRbwL9UG+8H59hghix36Zct32J02+p8JbBhU5eC+zohh9cnJJubtspSttc8dZ+zV soQe5BCr+tqHf9R4hgfyMYqQgMze1Z7Knf3RJIpOXIdRPnxz+5qCyUz89JNM4ag4A/Ge /O+dib2EbvwJ1oAXSz8mkqeTkB8PufsELwKOpoea0pKwyfMJVG9lbPs6JnbSzL1LH0Qw EgT+6J/dK9hA5pQjgiAjJOGW5l+xsxzCA8CDU2BMBGD8VemGn5PtFpOT/nE9jhsWBPDM lY7Q== 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=xChmiwQl+wmQW8P0Mtlmu7tO3wO/B0uNn3oxPfch9sE=; b=gOfeDro9MnYyT0NP2f9s84bTc4iVHexpKF51IYQW87ZJQPkDuzNmHX1JYQim8huqCS a8V0eLbw2J9sPq7QPuefJ/9HTiAkwLKniT8cbzKAgZeug7uyg96oQztOtVAWxE8rDVlP h9Dn4OHSsq5Arcl2515Omf0bPI4lZf2cPwoc5ld6XcBWIdzgAGS/gurXVBtLtPrmirnB QFL6R6yhuTXEkxbfDtO3AJ8UBJO+xaoVOgVJG9K85eVrrah1lNP0kUsHXp9u84a1NS0x ltTISwt88fVi7njUnI12PLEcLMj/1Qb0Z65Rr8a2GMKuDf4/d+cHzaCfgyxwXu/MDWup 54vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qwfgIpaq; 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 j11si16119002ilu.123.2021.05.10.04.03.00; Mon, 10 May 2021 04:03:14 -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=qwfgIpaq; 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 S234093AbhEJLCJ (ORCPT + 99 others); Mon, 10 May 2021 07:02:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:59424 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233314AbhEJKpg (ORCPT ); Mon, 10 May 2021 06:45:36 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 58FE96199B; Mon, 10 May 2021 10:35:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642958; bh=HbZVkDM7Hz1dYdhcBMw/0LW2l3hciERE9GIKr0uqtH8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qwfgIpaqxgiKNGH4Xq5xo9wyAdJrfj7W+B24sTSGyUkvGCgbYnTobLjG6hqdLo9HK uuSjC3uuHGjFXfk0A/e4JHje3BfsNyvL9RayDiH0kbws0PNbqVl8vtbU/yxTTDB+mb RVgZ84L3LEw7LnGfhixpaGpLX7Bm/yGe0PQMyKXs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mathias Nyman , Sasha Levin Subject: [PATCH 5.10 085/299] xhci: check port array allocation was successful before dereferencing it Date: Mon, 10 May 2021 12:18:02 +0200 Message-Id: <20210510102007.747032385@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@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: Mathias Nyman [ Upstream commit 8a157d2ff104d2849c58226a1fd02365d7d60150 ] return if rhub->ports is null after rhub->ports = kcalloc_node() Klockwork reported issue Signed-off-by: Mathias Nyman Link: https://lore.kernel.org/r/20210406070208.3406266-2-mathias.nyman@linux.intel.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/host/xhci-mem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 1ad0ac8c8209..8ce043e6ed87 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c @@ -2263,6 +2263,9 @@ static void xhci_create_rhub_port_array(struct xhci_hcd *xhci, return; rhub->ports = kcalloc_node(rhub->num_ports, sizeof(*rhub->ports), flags, dev_to_node(dev)); + if (!rhub->ports) + return; + for (i = 0; i < HCS_MAX_PORTS(xhci->hcs_params1); i++) { if (xhci->hw_ports[i].rhub != rhub || xhci->hw_ports[i].hcd_portnum == DUPLICATE_ENTRY) -- 2.30.2