Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp3161914pxb; Mon, 18 Apr 2022 17:43:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsil+k19uDYADOUmqnbIjJT8A9Zet5D7iGkiMt6cF8XajSTVfHXbBS5/d55Cp8kobZCHTK X-Received: by 2002:a05:6a00:80b:b0:50a:9293:cd5a with SMTP id m11-20020a056a00080b00b0050a9293cd5amr1646002pfk.15.1650328990345; Mon, 18 Apr 2022 17:43:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650328990; cv=none; d=google.com; s=arc-20160816; b=T3NXoFSzsdiCHSOhQ3yG12IWTcQpw8JHyUKFqQFr0h4rpExXOk1rfKtqFapqNd84oC C3FlxPRHo64zxqZ+8RmWyEkYP733n1nzpnLYuDhoV7vdbprobNW43xUyBKwIpkUFpWFw uhy6v3u8FZt+B2X5TbjhxSOlNoFjJEic8c5+uHa+dLEkyKkEZV+hIzq66Pr8qTpsMy22 +U/SmZv79iuyWY7Zzf4ePr+WRCX+uj45oePwEHnmaOthAIMByXItgcymzy0Gqs477bgI or55GcKpDBtyirmg4sHPkDOuKmnXbPjUiZ2aviYD0bLJ8TbOzX3wkc6Ae68ielkGxgun 5h6A== 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=XfboBGGsNlcb1HMrLFoqYyPRZZcCLPxI3GflJM4vHuA=; b=mKxQMXCqFOeAlhVa/KkzfyS+NmuqNpn//YSYWNzL9Zb0yZKR9wbw9xC0J6zUtZ0/q7 QsifeZuMslvUH0EhBmNDIEh6Mz1ZWkTxzUtHIjVb+0sCaCtedc3OKqQx/AWV8oHUz9Kf bmBMNCHdkK5aL2ra3oI89NthxVkTffCNPO8qr4qzud6rZGPSPSv7dmtPiorRa854XAgJ 5BV4nP3WnRGH9EgpNGK3g2S/S6j9XWKLtOt9Ft0wA9QO5mocY24KcARe6EgadN9WvsZD XUXKsDtQGSzFHrhhMAsneRE3h8ONlXuggmbpWlEN0jkhEkGK/gNqBuhgdz3qm0egtT3Q W4tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k2hWUgKj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t11-20020a63eb0b000000b00382274f6ae9si9856258pgh.589.2022.04.18.17.42.54; Mon, 18 Apr 2022 17:43:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=k2hWUgKj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S239148AbiDRMek (ORCPT + 99 others); Mon, 18 Apr 2022 08:34:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239464AbiDRM22 (ORCPT ); Mon, 18 Apr 2022 08:28:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 307CF21825; Mon, 18 Apr 2022 05:21:53 -0700 (PDT) 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 dfw.source.kernel.org (Postfix) with ESMTPS id ADE3E60F0C; Mon, 18 Apr 2022 12:21:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1438C385A1; Mon, 18 Apr 2022 12:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650284512; bh=65Kk+qldAVoXasIuRHp7X0cnQR6pzfjYHtj7UyV3JM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k2hWUgKji47BOZrgJKtmCHBEFY9haO4FfHTOM9HxTfZ+bMAMWagCOJ5i/vy3vcLB2 JY6qq4WUmZxz7AuWi97O3635ZRbZA+X9b6ANDoRPOM/eriD5FxojvyejcS+Jbvh+R+ bffkA2afGPnkxf68Pb+rE00ZNHhTSGZmXziceims= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, QintaoShen , Alex Deucher , Sasha Levin Subject: [PATCH 5.17 140/219] drm/amdkfd: Check for potential null return of kmalloc_array() Date: Mon, 18 Apr 2022 14:11:49 +0200 Message-Id: <20220418121210.811287033@linuxfoundation.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20220418121203.462784814@linuxfoundation.org> References: <20220418121203.462784814@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: QintaoShen [ Upstream commit ebbb7bb9e80305820dc2328a371c1b35679f2667 ] As the kmalloc_array() may return null, the 'event_waiters[i].wait' would lead to null-pointer dereference. Therefore, it is better to check the return value of kmalloc_array() to avoid this confusion. Signed-off-by: QintaoShen Signed-off-by: Alex Deucher Signed-off-by: Sasha Levin --- drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_events.c b/drivers/gpu/drm/amd/amdkfd/kfd_events.c index afe72dd11325..6ca7e12bdab8 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_events.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_events.c @@ -531,6 +531,8 @@ static struct kfd_event_waiter *alloc_event_waiters(uint32_t num_events) event_waiters = kmalloc_array(num_events, sizeof(struct kfd_event_waiter), GFP_KERNEL); + if (!event_waiters) + return NULL; for (i = 0; (event_waiters) && (i < num_events) ; i++) { init_wait(&event_waiters[i].wait); -- 2.35.1