Received: by 2002:a05:6a10:c7c6:0:0:0:0 with SMTP id h6csp2920174pxy; Tue, 3 Aug 2021 20:05:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt6uuGyLEX9qn5BCgIcOxEGXASAaL2ts3TgomDauRf0uA7EUhHwd++8ilmYnF8tS14RtqE X-Received: by 2002:aa7:d6cd:: with SMTP id x13mr29495697edr.300.1628046308710; Tue, 03 Aug 2021 20:05:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628046308; cv=none; d=google.com; s=arc-20160816; b=o1apVjy1YBj4WbLgY2xXe+aDNKRTndgE6Imj4BnfZo5kc3ChsN2JFa2xdzmQO3AGCQ Vxi93OPnxy/AkOh58Xa3gAXAQ3H6kLm7Za4kuRmM0/GOQcjKlwdtksNjxuNalnMFpfrQ jxnAWWqBHvQni8inV4ZtzpgWT2FS2PtPs7Ie+wqfmx4P0zYwDZNq0PI+NWTUuQsPBlKz CyduY9KaSiAZ83QS97ddxOnru5HaAG5rPbSdautBTgpRPTNL/bxnupkPyzmxnAnYICPR ZszisM7F+i/ZMMxbYvakUFtZsa22qgCBo7Q7WHOH5loJJE/NS4LiKC3f6EW6rGRLENVy MA9g== 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:dkim-signature; bh=fSQgo07VJZLrzxtRhVpF2elOIx5PWfCaTzxcdQTI7sQ=; b=PM+RD+J3e+H5PYQhF/CWYGHvRNmmOqokUwJSA8PwwEldK2aLOLEV3H6O7Q0eIZUPDW l7Svdw8QiAfcEltOpavZGfZox9Dy8cTQTfuU35PBmsHt2BtUGqGcbvM6yzV9CdQUjEEU KcyQijOzdi0pitI7nOiIqLPA+QrzZQ18AI4i/C0oH0LLxGy/Hmow4Q5NT45ZXiTI0Wye pZqxn6ih7DVjTJTtG/UfmDWjFFrQ9sna9dFxEFZMNR7yLHZ1Ddh0ky54NrrO41qT8o8A zG+QKTCrqRk+BI1ciCM8tuGDbCZXDrNkaSxzNazMtczOmOsa3aC4iZixh6bB6uLksgU8 iOnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=AH1zW7BE; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w18si799301ejv.669.2021.08.03.20.04.45; Tue, 03 Aug 2021 20:05:08 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=AH1zW7BE; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233958AbhHDBwl (ORCPT + 99 others); Tue, 3 Aug 2021 21:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229820AbhHDBwl (ORCPT ); Tue, 3 Aug 2021 21:52:41 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1316C06175F; Tue, 3 Aug 2021 18:52:28 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id mt6so810208pjb.1; Tue, 03 Aug 2021 18:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fSQgo07VJZLrzxtRhVpF2elOIx5PWfCaTzxcdQTI7sQ=; b=AH1zW7BE9omAKOjq4atorPk+57PqXqxm72okT/sJJeaB/KGSI/yVXGbo+or5iSV8DM Nzn+Op61BdpBBK2z0eQ56R+86cH/pdH1JvRsF2MLdZdLN9QyF40cAis3V+3r+gys6pLF Wt5nbPEidUbNwkSB0bSwwY/NkmoH+2qcmUVnwUGZ/MVha1n4bzf99cl4kCeR9U37tb6u 9ETOoeec+DlA30Cp/wA7qihjWYeg+EISnWTAmlGvj/kipYID5haaaGyo4YUdfN4Eghv2 1ckHyd5/COwgsJu8mDz2pcuozW/teLegKpb3Vkpb5WSx3f2bDQG3tuazJVz028oiSn8M YmSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=fSQgo07VJZLrzxtRhVpF2elOIx5PWfCaTzxcdQTI7sQ=; b=g5W5GV0eghePopbpFN8w8vRVPZ5KlNtJZcISIMwzQZsi0SDr42L9rDEAAU6DCXR6vg 5/FzY5lnpWcBGi1ZtK96dY8SDCMpOwZTqMr9zi7Rm26T/p7scyZS2fhgAnMFjUDukiPH chsUQKyenwVqtt0uOJsR5M6X1V/i2Wu/NY/hUAbCK2iT/83lylpC6GQBOj64uvQjcnW6 fFDh09Jqn5UWQ9Pxu6SREOwSfnuuVnaVZMxiSX2PH3BiHMY7VOQtr4Vre1CSgoRV1ktl sGaQ7Y3nNrlyQpBoyXXTWeRX8HgCuTrcRnW++DifTTz5LYuLL3w0FEf2oGQ9KeCqSKdG Q8gw== X-Gm-Message-State: AOAM530FC6s+U4rYYVg8dbPuwMNZx2uZSzaw5zWLoZq+HFwpEGTTjb6d 73BUrmE2kBZPaz8Pg3DUje4= X-Received: by 2002:a17:90a:ea8b:: with SMTP id h11mr18676578pjz.157.1628041948277; Tue, 03 Aug 2021 18:52:28 -0700 (PDT) Received: from localhost.localdomain ([45.135.186.49]) by smtp.gmail.com with ESMTPSA id b12sm496069pff.63.2021.08.03.18.52.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Aug 2021 18:52:27 -0700 (PDT) From: Tuo Li To: alexander.deucher@amd.com, christian.koenig@amd.com, Xinhui.Pan@amd.com, airlied@linux.ie, daniel@ffwll.ch, sumit.semwal@linaro.org, airlied@redhat.com, Felix.Kuehling@amd.com, Oak.Zeng@amd.com, nirmoy.das@amd.com, tzimmermann@suse.de, Philip.Yang@amd.com Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linaro-mm-sig@lists.linaro.org, baijiaju1990@gmail.com, Tuo Li , TOTE Robot Subject: [PATCH] drm/amdgpu: drop redundant null-pointer checks in amdgpu_ttm_tt_populate() and amdgpu_ttm_tt_unpopulate() Date: Tue, 3 Aug 2021 18:51:32 -0700 Message-Id: <20210804015132.29617-1-islituo@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The varialbe gtt in the function amdgpu_ttm_tt_populate() and amdgpu_ttm_tt_unpopulate() is guaranteed to be not NULL in the context. Thus the null-pointer checks are redundant and can be dropped. Reported-by: TOTE Robot Signed-off-by: Tuo Li --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c index 3a55f08e00e1..719539bd6c44 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -1121,7 +1121,7 @@ static int amdgpu_ttm_tt_populate(struct ttm_device *bdev, struct amdgpu_ttm_tt *gtt = (void *)ttm; /* user pages are bound by amdgpu_ttm_tt_pin_userptr() */ - if (gtt && gtt->userptr) { + if (gtt->userptr) { ttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL); if (!ttm->sg) return -ENOMEM; @@ -1146,7 +1146,7 @@ static void amdgpu_ttm_tt_unpopulate(struct ttm_device *bdev, struct amdgpu_ttm_tt *gtt = (void *)ttm; struct amdgpu_device *adev; - if (gtt && gtt->userptr) { + if (gtt->userptr) { amdgpu_ttm_tt_set_user_pages(ttm, NULL); kfree(ttm->sg); ttm->sg = NULL; -- 2.25.1