Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3654799pxb; Mon, 24 Jan 2022 14:33:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoe//OItvV2tRRPR8uK2hxuVuZtLp1yU42TjgXDmUVeZKOQxZtfk2YoSacrypCtriEMcOV X-Received: by 2002:a17:90b:17c4:: with SMTP id me4mr433942pjb.198.1643063585304; Mon, 24 Jan 2022 14:33:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643063585; cv=none; d=google.com; s=arc-20160816; b=000tPK1+CP5uqiOzweaEzeAIhKCW6eZOL77Sr52gnU+6lWvjUmb64JEzpiGYkHmvx7 A/XaVpSlaME6qbVkNSbaECgXUP5dNYhPxgqH+uAKRZ0s+weS+UTbvTqbJ/MU+1i6Xd1I FAzyo6ApA0l7bjDgg4D/7RytIqIJhopRXwJyzzgVL6fqkPIJpS4vJboD6/8f5D2RsZkk RT6/2TJyMVPaiueHLG+PoNsmyyI0V5OZLIGbZL92ECdK37igfJhJieAn+O/jCI6fjdId 7pi+gDYqEOU+CBnJkYXOEbUFnmA+4VMAfkJSoH1fL/qc5UXXCFmcYGCcKouLDHTED5us pJ3g== 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=/32yO54Pru3rfQiBU/1BDkz8wVkcO9eXpP08+cHdOb0=; b=EfncYiKjx18my7uTLVWHL2prsFiOb9HiT/HPfdtjkovKlCPaC7e7ZlizLoAdC33oPn fyTjXt9Gls3IGtVxIjo6AM058h5R4Q5O+GvMec6gEXy+927TrXB2EDLRV3eZDG0qNQN5 nxcdLzzmNip1ycj1zCqCIMbstoLD4/edt7qToXr9HJn+DhwQX1PCq8tsHUEL1o6Lw4aj 0akIX+97UfeL55ct0PHymRtV+KNg8ie9NEvTQQeahJclav+SI8CuO8dIynxlIiEZtGhw tc/v4SnYHsma8twR+jQrmnmmcZgS8Q3Hakr2+HYMoSxfvZkMhbL/vNETnpZQV7Wmz+i9 AHuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gqdRlHxt; 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 p3si16903486pfh.144.2022.01.24.14.32.53; Mon, 24 Jan 2022 14:33:05 -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=gqdRlHxt; 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 S1587359AbiAXW2L (ORCPT + 99 others); Mon, 24 Jan 2022 17:28:11 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:47052 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1454982AbiAXVeQ (ORCPT ); Mon, 24 Jan 2022 16:34:16 -0500 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 CC08DB8123D; Mon, 24 Jan 2022 21:34:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EC18AC340E4; Mon, 24 Jan 2022 21:34:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060050; bh=zDHN0pvH5VbPZU6z9GYhPXlHtcv0MaHvgRH814qRAaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gqdRlHxtnuHtzvuK5LNvObnS9JU9UAw0zG4gjRz+V+udDzzXaW/sylwHwkKeuXBfK spGGOjseoLlEDZvyPBI+K9ADqnzfQ/LifdRUofFCCt7StR1qlNxjcChFNfDQJkBkFl FGgviaIH+zy/7FJczD3+MX5YoxqHVvHcqFVw/y1Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiasheng Jiang , Felix Kuehling , Alex Deucher , Sasha Levin Subject: [PATCH 5.16 0822/1039] drm/amdkfd: Check for null pointer after calling kmemdup Date: Mon, 24 Jan 2022 19:43:31 +0100 Message-Id: <20220124184152.928542031@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: Jiasheng Jiang [ Upstream commit abfaf0eee97925905e742aa3b0b72e04a918fa9e ] As the possible failure of the allocation, kmemdup() may return NULL pointer. Therefore, it should be better to check the 'props2' in order to prevent the dereference of NULL pointer. Fixes: 3a87177eb141 ("drm/amdkfd: Add topology support for dGPUs") Signed-off-by: Jiasheng Jiang Reviewed-by: Felix Kuehling Signed-off-by: Felix Kuehling Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c index cfedfb1e8596c..c33d689f29e8e 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -1060,6 +1060,9 @@ static int kfd_parse_subtype_iolink(struct crat_subtype_iolink *iolink, return -ENODEV; /* same everything but the other direction */ props2 = kmemdup(props, sizeof(*props2), GFP_KERNEL); + if (!props2) + return -ENOMEM; + props2->node_from = id_to; props2->node_to = id_from; props2->kobj = NULL; -- 2.34.1