From patchwork Wed Jan 4 17:56:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dragos-Marian Panait X-Patchwork-Id: 13089329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67B75C53210 for ; Thu, 5 Jan 2023 00:47:11 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 001F010E100; Thu, 5 Jan 2023 00:47:03 +0000 (UTC) Received: from mx0a-0064b401.pphosted.com (mx0a-0064b401.pphosted.com [205.220.166.238]) by gabe.freedesktop.org (Postfix) with ESMTPS id CB04810E07F; Wed, 4 Jan 2023 18:26:13 +0000 (UTC) Received: from pps.filterd (m0250809.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 304FPeLq020752; Wed, 4 Jan 2023 09:56:48 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=windriver.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=PPS06212021; bh=Vaio7YrSAPXlij4IH9/aay1Ifg5Rf4oWjiyu1XcDCjQ=; b=A3gGXi32SWDIIiof4JeCcYDqk/ln18DS5hTTAjikfUUjK5pH12e5Y6gR/a7be7kWmt4o X+kvGMCq+j6Wbo50ZUztJ6btMzqMThp3SPl0bXjUVqzDeTtBGsylUVjODMNPX21IJ2PO E1Ljjn7no3u389MbrVduq4ClcnAWohnoMZV4Rqrk8iZ/+8+byb+PrCRIt8zolpItJUO4 5y6qiJ1sgEWs3Jh+8vdHD/uzZtdTfohVz2oU6oN6nePSLPfrd4jG3N1+UdH7m02VI+2o fNzYv5ZUFZq1K9o8ZjEyUbH9Mrw5hUAxyKMHiRnGgNHXFZ3jyCDkvh+plvidSxkpvceh Fg== Received: from nam10-mw2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2101.outbound.protection.outlook.com [104.47.55.101]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3mtnfrtfff-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Jan 2023 09:56:48 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bPcKCCuqm9ODuEp8f6QciayVBqLZJaZhcWMg4oq2p37x6h9ONq6gR3fxttXusBKSzoUXLtJKHk/9MuOPTzB4HMMynAkMhiN+vimTL1x1uo4MV0U1v8SvDdXUWVMszylWxE6Aefj2+jRt1P6PR0qtoCp6tmNbvpFgTH3xlHS2erJGVsmBrQpIpdz+u9pEbkJ/PSiju38k05mt7VaiW5NgT2Yche1/Qdqu9Sna/iQVR13J3Zew03p3342WpDm7TEo4/U90xjAdOzQSvU5rZmyCjNDa++OiXlDqMxobuKQhh6tu4yQ56r5GS23Y+L7H/zjd8uCnwO3Ly64OQ7s2AMbMnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Vaio7YrSAPXlij4IH9/aay1Ifg5Rf4oWjiyu1XcDCjQ=; b=Zs6F2Yfp3aG9sxTzhdjeazjoSylODX1YjKTrvT/F4ww3qmDeuK2+qhFjtPGZDA4VMlq1WqWOyPY3NHwNXp1ZCEG3NqCvI0U3tBDwrp1tfLibYz9Q5BoGz8ihbSXsGJJtgNQvvjGZneP/YlWtq2+xm2Vl+Z4pgb6GJbfT7zwOaBhItFGF/EoSHRsvwKZVpx46mxtRUZbMixjtnlKX5RdFWVt125QfAYKR5yr4MhhSkczas3QUn3SyIURZgFfy/oz8N5RJLhhx6DnRBbjO5zDJ+VoR0W1zLrDUfmtGjvBakczNLyKFK9ptZu9HcMgy6qgpWLMUJUIaG8FXMfPV33Jbfg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=windriver.com; dmarc=pass action=none header.from=windriver.com; dkim=pass header.d=windriver.com; arc=none Received: from PH0PR11MB4952.namprd11.prod.outlook.com (2603:10b6:510:40::15) by BL1PR11MB5462.namprd11.prod.outlook.com (2603:10b6:208:31e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5944.19; Wed, 4 Jan 2023 17:56:47 +0000 Received: from PH0PR11MB4952.namprd11.prod.outlook.com ([fe80::52f4:f398:b983:2380]) by PH0PR11MB4952.namprd11.prod.outlook.com ([fe80::52f4:f398:b983:2380%7]) with mapi id 15.20.5944.019; Wed, 4 Jan 2023 17:56:47 +0000 From: Dragos-Marian Panait To: stable@vger.kernel.org Subject: [PATCH 5.10 1/1] drm/amdkfd: Check for null pointer after calling kmemdup Date: Wed, 4 Jan 2023 19:56:33 +0200 Message-Id: <20230104175633.1420151-2-dragos.panait@windriver.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175633.1420151-1-dragos.panait@windriver.com> References: <20230104175633.1420151-1-dragos.panait@windriver.com> X-ClientProxiedBy: VE1PR03CA0059.eurprd03.prod.outlook.com (2603:10a6:803:118::48) To PH0PR11MB4952.namprd11.prod.outlook.com (2603:10b6:510:40::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB4952:EE_|BL1PR11MB5462:EE_ X-MS-Office365-Filtering-Correlation-Id: f63a7d30-7a7c-4081-b963-08daee7d0c5c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QIXh7NFvo6/0jV1HXMSrkpUS8y/ssvVFjAhlJW0DRnyR0SzpNDatk84pJZlcVY2yFWZgQcHCX1+5NkuaY5a3O2JLqGeMikD6P1U+HXA/GEcPbrsVYQ1Tl60i1QzEcIMf+sGQtIjWd1m6VJ5qtg2YuQl3TC9ccXilHj5rpySQrZRJqv9LyoM16Fg4A32To4d0O0Y1QDevMFWDhJqUmoqNW0Htjh8xm6EuZRstM6K9y9+gRXWW2gCDbPdZWL9uN54oabjG4GsWYA/mqqFlUrV7/MFzLr0JTt2rqT+K1gkTQkjT3b62VWlYtk0Xm/coETypDLk19ITDdz6cg28/dyWvDYHDdAKWHYWUgye85TZyic8fxnkHZFvsHxgmR2DDMC2UinLg/PvEfI96G5Ve8r5uNl74OaDAGQEr+9MGgji8eBeNBjOA5zIlF41lPCbez0u73dqzu9y8pPYXQUD06aJ9mrhkncNsfr0vK3MUW56SaG0r/xZYdCT6JV9evwgRqJMtkEsLngbk5aziExjPVNrdfvrlMUhSCgjwCAY9ksnNZ/sdhF+Y8jA81kkb8Z+o908lCgyz+C/Q4mInsxAKPHwB5gwjEtPKlpehNo403lpMGNMZPA/luRO8dNToMpuN14KftlBLeHRJWAVpttf+nG50+ViQ7GynuQ/axDT7SPQIvUJnWqhCQutkNoqPRw7Lsv5v X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR11MB4952.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(39850400004)(136003)(366004)(346002)(376002)(396003)(451199015)(8676002)(4326008)(66946007)(66556008)(6506007)(66476007)(478600001)(6486002)(36756003)(52116002)(86362001)(54906003)(38100700002)(6916009)(316002)(1076003)(2616005)(38350700002)(83380400001)(7416002)(41300700001)(5660300002)(6666004)(186003)(8936002)(2906002)(6512007)(26005); DIR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V+fCUtv+BDWdjfIDOTJ8HhuP8VTARXD97RUOv26Ao93a5qucLXoJghVUyqw1q0yZySKsiIw1HhsKMPaEZE/tOriigs1TsXOHPtPP1GWC+LRV2Wsh/+7MdwwN8pSquxoLXZhs+UfLFQycnkC+00fQ5s5TB/XuwjG4miDNTVEXtiE+MJ6MeZfoqFyL4UuNKZdI/Uawrxz7FIiqx3a5l6qW/lcbEU/XDd7tnkcS0dIehzSdEwf6YeypPChwrwO+0j433MBOTSU+zcMzzkFVVZSz7Ihw5+mCTzNQaWVKlij5cMYfw0fhp4Rvrik8aALFY5POPVkkXvaIY8noRcTJR1xeOI2QD/ItY7ZGJZu62UUC7YI382Lcmww59nxXg4PXutJAmYnAm3e3HOxjzdeq78uFB8HJZY4ee1CqgswFt6bspBsU7AAxKD/PFwPAKmDFiGs7AR8ILznH+Z/Fx6oF/CVXWxVxogVThpRKav6rp4ngak9sgmPSKgl7VnaB7qxLav1fzphv75OkI38BmNOwvF6up0Tr/SWVyN2e962mCdGpQpx8ZsdBwlJuWsr5dSXFH7cEmBR9Ct9E1l84WxYybreTvb3gaXymc3SYEtL0jtg== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: f63a7d30-7a7c-4081-b963-08daee7d0c5c X-MS-Exchange-CrossTenant-AuthSource: PH0PR11MB4952.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2023 17:56:47.5040 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ddb2873-a1ad-4a18-ae4e-4644631433be X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VlWAPJHQWHh6FLCIsR1rrNQRZrXaODlIG2FhujLt/eyMrJLHWzyZRK36vvkcSpHW4J8eCjbjBPKlsMUUc7WkqKLzH+pSTXnvIMctWBZPj94= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR11MB5462 X-Proofpoint-ORIG-GUID: JwwY7w5YdxMeYnazvQ3pWxC_0R0rSZVo X-Proofpoint-GUID: JwwY7w5YdxMeYnazvQ3pWxC_0R0rSZVo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-04_07,2023-01-04_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 bulkscore=0 priorityscore=1501 adultscore=0 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301040150 X-Mailman-Approved-At: Thu, 05 Jan 2023 00:47:01 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: amd-gfx@lists.freedesktop.org, Felix Kuehling , Jiasheng Jiang , Harish Kasiviswanathan , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Kent Russell , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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: Dragos-Marian Panait --- 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 86b4dadf772e..02e3c650ed1c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -408,6 +408,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;