Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp4996846rwe; Tue, 18 Apr 2023 00:02:00 -0700 (PDT) X-Google-Smtp-Source: AKy350b32++Z1jDLnAjdYrI4DgyMW/X+jdPKeHbHOrnXRy5AD0y0V1SD6m4G8YyJtf5fu4GvzXq9 X-Received: by 2002:a17:902:f90c:b0:1a5:2b9b:67f7 with SMTP id kw12-20020a170902f90c00b001a52b9b67f7mr1019213plb.46.1681801319769; Tue, 18 Apr 2023 00:01:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681801319; cv=none; d=google.com; s=arc-20160816; b=v6bvLLn8MwkjnTl5VX1btDVldtjBueMYAJB87x8I10LPUugkzNNTndhcxI7DvKWBna EAmvJypoIT5OhNDCKbbWR4uLuQGI4vLz1QubTkMELq7+/6IQv5YTqM4MmawAFYz/44bA Ra+gHyzbaMnN7l0WDH1vdODt14yoAwQYPOGV7+9XUBwmcvW4XnBoLzHBlUhDqhjV/5F/ sPPTG7MMbk5dXZPqooikDx2FuOPc6OyTLIH3Gugc5ZZgedq8e/dWQ4uthMBSimr01+lV Osjw3Xe7g8SRfC3yVsaxBQmJ9K+gtUhKLWVYWXgYnlJzMiS2qajRj8KQQCaMn4CQU72h 5JuA== 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 :message-id:date:subject:cc:to:from; bh=5iL9yRst2huEhQkbbzmnxGefvNNvJjPU9j7tB6eRqJA=; b=XRiRD9ZsbObRcdWUq5NaQT+PJbF5cKwNSiXEaNwrYDqnvpMXMD3xuRCSzlA/HX9bXd C5mkT/6ygMlqgK/sYgIx728G82waERtkS4FcIAQRQXlkNk9Xviv+PS8xEoORPg3yOcbO cKHztHqd9mGAIlO6Fn6iUKgsAO9zNeh2K1D1uBdC0/63RQYtSLCzihsFXnty3u0F6as2 0S3/eMhhX0rTjbHNyClP+3iak9l3DuM2ncoTpf33aXR4VYuoWSEL0iaBF9V5CrgbwgbG rdfcr6k7YmSfCXU1ve/CDXlbuiUR6/boc68n5YtG6DNSdmoPz/dou/vGMHQ7851ciwLU iUJg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c9-20020a170902c1c900b001a20c983d21si13483034plc.51.2023.04.18.00.01.44; Tue, 18 Apr 2023 00:01:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=aladdin.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjDRG40 (ORCPT + 99 others); Tue, 18 Apr 2023 02:56:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229535AbjDRG4Y (ORCPT ); Tue, 18 Apr 2023 02:56:24 -0400 Received: from mail-out.aladdin-rd.ru (mail-out.aladdin-rd.ru [91.199.251.16]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85D935BA5 for ; Mon, 17 Apr 2023 23:55:57 -0700 (PDT) From: Daniil Dulov To: Felix Kuehling CC: Daniil Dulov , Alex Deucher , =?UTF-8?q?Christian=20K=C3=B6nig?= , David Airlie , Daniel Vetter , Oak Zeng , , , , Subject: [PATCH] drm/amdkfd: Fix potential deallocation of previously deallocated memory. Date: Mon, 17 Apr 2023 23:55:21 -0700 Message-ID: <20230418065521.453001-1-d.dulov@aladdin.ru> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.0.20.32] X-ClientProxiedBy: EXCH-2016-02.aladdin.ru (192.168.1.102) To EXCH-2016-01.aladdin.ru (192.168.1.101) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Pointer mqd_mem_obj can be deallocated in kfd_gtt_sa_allocate(). The function then returns non-zero value, which causes the second deallocation. Found by Linux Verification Center (linuxtesting.org) with SVACE. Fixes: d1f8f0d17d40 ("drm/amdkfd: Move non-sdma mqd allocation out of init_mqd") Signed-off-by: Daniil Dulov --- drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c index 3b6f5963180d..bce11c5b07d6 100644 --- a/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c +++ b/drivers/gpu/drm/amd/amdkfd/kfd_mqd_manager_v9.c @@ -119,7 +119,8 @@ static struct kfd_mem_obj *allocate_mqd(struct kfd_dev *kfd, } if (retval) { - kfree(mqd_mem_obj); + if (mqd_mem_obj) + kfree(mqd_mem_obj); return NULL; } -- 2.25.1