From patchwork Wed Jan 4 17:51:55 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: 13089330 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 8C96BC53210 for ; Thu, 5 Jan 2023 00:47:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5B30510E104; Thu, 5 Jan 2023 00:47:04 +0000 (UTC) X-Greylist: delayed 1797 seconds by postgrey-1.36 at gabe; Wed, 04 Jan 2023 18:22:19 UTC Received: from mx0a-0064b401.pphosted.com (mx0a-0064b401.pphosted.com [205.220.166.238]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5B91110E463; Wed, 4 Jan 2023 18:22:19 +0000 (UTC) Received: from pps.filterd (m0250810.ppops.net [127.0.0.1]) by mx0a-0064b401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 304HbV6q024499; Wed, 4 Jan 2023 09:52:15 -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=l3e6I94k/ZqWPDWhBXjDOWDqowM6L6nKdKizhP2ZwLM=; b=ciSWUKFS/I2ixoyv+/b8K7k1QeFQemyzPYvQdDzCh+wkYJcZAlTfTX0Oe/pzoUc50XtN cNPqZT6+RKysrl5PVxw6cmE5K5O7SgvKKg+kWXIcjHfGbjIMvnVOtoll3OzJE0GJJB1A jKF6D/sqaZrdImjke2flB/sVAFTSUyHxmrCFyUHGZxExNfa7fdeFr7BhVsY+QOwU4sDK NzcwdaEa/JV/Tm2ZXzD2sC11HLDNhmlkTOV3Menjm4nqxAHLgy14CXEpk43j1WURCuYq iwWGdFRfp9XnnNBILwU/hCH7EgrAOZtUfZRjXPOgiJDQ1d8nfWNLT64mlO4UG7cyeu5B MA== Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2172.outbound.protection.outlook.com [104.47.55.172]) by mx0a-0064b401.pphosted.com (PPS) with ESMTPS id 3mth87tj0g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 04 Jan 2023 09:52:15 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d3oodw0PJOJyCw0xHzbW85dGVjlwsEwhQrD75hXhYI5aiKhO36JZdy4Pg4pJ4YYS9gIWdwQxUI+Y4p1et5H2hPx584MptP7a9qNKCsOjIg0Xm+gP3djAVjqzIfvsFCy0INZChOGiI0hvezzy9TJ1jbL3sbhjaw+W2EtWz90oTVrMo/XSYW533a05ees40k3BdGfXkTm8f40E29fqqwC/Ldbet5x+V5uFXGuSUM8358bT9K8ClpvkwolKfXNba2eOqomG/DcrhtTjEPBjzvjUnyse50YWwldlpmwE1tXDPUXPHLsmzl9hE5Ldt83dhUJZRbug+Q+8gjSeTEJL0PuWXQ== 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=l3e6I94k/ZqWPDWhBXjDOWDqowM6L6nKdKizhP2ZwLM=; b=UmjOsZkyLEvmpiLfB2AgoCFXz2CtpbsXptH/dCpyKnpBTJIl9FEDvNoRmj3X/CGSKbwGnzbdYfRd2n+pWNH5p8izlIFAKXNM3ZB5ld0OZ4lUWLtfVF3i23MsspcC8zFF09DSesNTQ9fMkw79toHW0h29pWU2xNSHkNbOBNWHUsXLX+bE4yHoD84lWLx81kGST1y2VauEoKn1MwgWaqGGq6QzAXtWdsItI6N0IkepU2DmOQVZ9he+7uNdMWSnrRjYCO1peePhkJrGnpZyZB1L8TrjpfrsDqMyeXh9us2jXHCQjcYn+bDSE4H8AZghJAE/hkfQz7UgYRqbV2vZzJ6uwg== 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 IA1PR11MB8223.namprd11.prod.outlook.com (2603:10b6:208:450::19) 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:52:13 +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:52:13 +0000 From: Dragos-Marian Panait To: stable@vger.kernel.org Subject: [PATCH 5.4 1/1] drm/amdkfd: Check for null pointer after calling kmemdup Date: Wed, 4 Jan 2023 19:51:55 +0200 Message-Id: <20230104175155.1415258-2-dragos.panait@windriver.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230104175155.1415258-1-dragos.panait@windriver.com> References: <20230104175155.1415258-1-dragos.panait@windriver.com> X-ClientProxiedBy: VI1PR09CA0133.eurprd09.prod.outlook.com (2603:10a6:803:12c::17) To PH0PR11MB4952.namprd11.prod.outlook.com (2603:10b6:510:40::15) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR11MB4952:EE_|IA1PR11MB8223:EE_ X-MS-Office365-Filtering-Correlation-Id: 36b90077-4c79-41b9-a364-08daee7c6926 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 1B7XktFUfAN92HRmfWh5hix/hCrbRdoFE+Drruky55/5HoSzn48HdoVwqZrDgmKNMlMCcgR2gHTq1eUVT1bMl/5zus+YH+gWKlnh3eAou28WdSLpbbS0JEseuZog6QODT6X9Nn7ClRnG8ym2xWy8jUcXoPitakpeGIMQDR7TWdEZwkhPkS6+AcL58ENCHw0Ec7eqYStM4URSI4lCXsR4J4QRIjnlnLqUC8v8gObs4gxmcmo5MYLmELmqJ35zr5iL/VbT6iHjQhmWGmtPrMIJdNC06DfgD/h9K8Q+coYP3d3zUZhBNtccq5OB2idsRZWerZC3saCwqKpPK/Ah+mqH6v5wrcf/EZDmQVUftG5v1EdtJ+oQyFcUJlS9aiX1Bb5/EjLVQAm+KnpljN8NRqm5MTWTv+x6A/UtLfNz+xDNcmpd33OuwGwltugPWVwXPiikRHDSQ8nt+t22IBVT1hSVGxnJ116KPAmLM94S0xMdJ9bjHgd27CqQAb2rthPqiJ9q+6MSZyUT6n+A+R9lySVsUH3der/6y5BMZujBpP+COo1kLPXR8FPTZIg8u6SKnb8OpewtcUHxu2W0wnSrVdRqEkYlBFKJrzLSkdFXvis3tT1vbk04HNL1Qh8s+IGk9AfTh3WbRTJAdx7+Z00BRbcW8i2zy4LLcfvG0MBt3jgatizt6t4WiKsYForCg2BdWBFR 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)(376002)(136003)(346002)(396003)(366004)(39850400004)(451199015)(38100700002)(38350700002)(36756003)(86362001)(1076003)(66556008)(6916009)(6666004)(6506007)(2616005)(66476007)(478600001)(6512007)(6486002)(186003)(26005)(316002)(52116002)(54906003)(8676002)(2906002)(66946007)(41300700001)(4326008)(8936002)(83380400001)(5660300002)(7416002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lm78rsaq7+SFoiKqGoxiuGhTjRbtS6U1pnE2U/EByzzgJDQjADf/6SShPmsTFY+YqcDNKjuv14HwfgdJ6ShzQfrllp8NQ7p8i5oN0gydGB6mf05huLGbOUe4WstvtXvjxIZUcsjHu8MxHbpRajtYsazNVUDj9GcdluqJkOCIwaN4ZDo2uYoA9MePfuEnG1OfSiRYNiqjUKT+eB2uZcbvszg3SK2h1ur7f6EMQ9Ru2WxKEwJKuvDU0JMH+RrhDlYhkel5xl17423mZp4IeocFyQluUJe5noT93nHtL1PRw61Z4c1tWUxRJu+LG65e2VbrV5qmpNw2wW3Evi94fgDORRDuDhXsIBRs0PBwMqS8iChqvn0D8HUPHLD3sTXW2HhbUhACtlWQMoe71YsBrhNC2gNINQkVFWpJfW9gzg25TjwYVW8tPRhMrQx6F8xeVg5rS4Mwyk7P1w3NDxpghB+OTcQ8LBhHA4TICh3fDdDMXo116H4CLHbMntasKmg7MehSw0/BADUl2sqr5M0HyC7WLOldWsEOhc7CYeaYAXRz4GgG2UlNed24ekiiJ9ehOFZqB+F/rfY6ajxgVm4/Uj0Vu1aMFfyQ/Ed/VbzKtLjk3az4+EUZRbEy15RWpq4+RPm0n/cYhFET2g0gKG0B5KOOkCPGP/oHsTDfniEzfFYmSA4k4sDmYIORGIlHS3d40v2mun7BUPoPoMSLvuJWRHj8c0riprIsMV2VabLCYg+/bGFnCEWPwcuyOK9e6Ib/GHzce9wZjH6naEQDCw8RoWOP1YKmk6wMB0rzZJaqPOFANPZkZNeWtBKhNNNe73aUhwar5CDvXj4AtFebBBac16IjQA8LV3rPB25P9E+3ha05p5vIAwpBdTg/fbe2jPj07k6WCXLxy1ftv9ow9cWOVSitD967XFmgi+dDQDuSxcZyKM8AfioonATIlmhBAh73A/ITQnUKZlAxo+T8OLhXXjyxASlPp4Jt5Gnq2VI67s/C6NCXqc8MrPFnJZOK3IOB/vqgviwfUUpXo6tGeKLmoiQvGvj6BcTt9QO/HLggQYKwuvJaXT4162svgNx3KLRFnUq31H2FeXLDv4NkwVvM2NZa4BLFWd5p6IvMQyRw2JA3B7T5n+lZawLhcQVqtXo0NeBxxdS9iJeL9CLcF7nglVdI26ug5wT9kVy/oZ2PQ0jsbzDmg64pm/Q3FXu7F2kdIgN4laXQlPSXTQroWUfWC5GGx1CVadksc4apjz75vqMa/zZZN6cp+tvmalYF9wSc8OTehsA5cxnA3s0eUxf4kPQCGczWv/uctcPSA3QROsU6n8c6DvZ1/hpO2IY0w49gCWpH0MfNW0+y9ctGgoAxXhYJ1vwILUTl1CbuyeZiolOQJFaIgeeoOAvnnDAMHT4FX1mi5C/gw7i+CsJRlPIMdUBxCZ6bM9FiVu1BXKV4MrkHEi0FrZVVx2g1COpQcWqeA0atPyxQfUFVLZkE1FygHsZEVal/py25RFM+zr8qC/i85y5+ll3EiS6ogl9Qcem0+Fl5WwNCDQLT43opXzHkFESthM2dr1o5m6B6WkX1Ppjy1sKY+eaij81MUfOrQyYZv7VOpAD9AD5mLC9zzCZe///Gag== X-OriginatorOrg: windriver.com X-MS-Exchange-CrossTenant-Network-Message-Id: 36b90077-4c79-41b9-a364-08daee7c6926 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:52:13.7766 (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: aWoAkdxrKeqDVkDlgycBZQbRr+ZBjEmlg9sPaESrOC6eWobF0A7/Xs1lh57HTq/lRS/6agKdZVOlUUYFrkwyj4Ha7Hrvhpxu6GZViqeGY7M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR11MB8223 X-Proofpoint-ORIG-GUID: pikKZc6x6uWbdP5WagCRtQiUoIRpmNcG X-Proofpoint-GUID: pikKZc6x6uWbdP5WagCRtQiUoIRpmNcG 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 spamscore=0 adultscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 impostorscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 suspectscore=0 phishscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301040149 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, David Airlie , Ben Goz , 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 3685e89415d5..6066cd7a9d8c 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_crat.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_crat.c @@ -407,6 +407,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;