From patchwork Thu Jul 10 21:54:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oded Gabbay X-Patchwork-Id: 4528871 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6C7EB9F37C for ; Thu, 10 Jul 2014 23:34:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D51020204 for ; Thu, 10 Jul 2014 23:34:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 7606C201B4 for ; Thu, 10 Jul 2014 23:34:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5F31D6E7D3; Thu, 10 Jul 2014 16:33:30 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com [209.85.212.173]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D0646E01B for ; Thu, 10 Jul 2014 14:57:18 -0700 (PDT) Received: by mail-wi0-f173.google.com with SMTP id cc10so5333571wib.12 for ; Thu, 10 Jul 2014 14:57:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=0Wzzqym+7BH39Yvd3VmnSOD3hQFOf+Md8rZv5WBTPKs=; b=iTuyS2koi4bgqTGe3/rGkZBoP/eehknj1BwTK+qDiXBrXy1bWmtytm7WxgaC1uZKrn /F9MlBzOQUH6u4pkImIKf3rUuttB9nVz8a8O/lXRzpMusl92mJkrBGuZjp6jTT95O+l1 8d2dUUiAUcEpTGMerORKdBKvHIXuonPYq72X3ykpNWFeuOHGmqYXx2/JsafKp+7F3cjA fO9xLMjvJsQVOKKh3ozM8TafdmKstTbbeqeQdadXjcEPrXb3ILuhgAZdn3FE2pe/qo0T QqEpqET+9m8XmEFZzzBzFrmQ0133FWR8/cApp5VbRiqkyHV1mGQnIEp/OiE4rinv0ghg 1e6A== X-Received: by 10.194.88.199 with SMTP id bi7mr60848997wjb.79.1405029437809; Thu, 10 Jul 2014 14:57:17 -0700 (PDT) Received: from localhost.localdomain ([77.127.59.49]) by mx.google.com with ESMTPSA id pq9sm831097wjc.35.2014.07.10.14.57.15 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 10 Jul 2014 14:57:17 -0700 (PDT) From: Oded Gabbay X-Google-Original-From: Oded Gabbay To: David Airlie , Alex Deucher , Jerome Glisse Subject: [PATCH 72/83] hsa/radeon: Static analysis (smatch) fixes Date: Fri, 11 Jul 2014 00:54:28 +0300 Message-Id: <1405029279-6894-44-git-send-email-oded.gabbay@amd.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> References: <1405029279-6894-1-git-send-email-oded.gabbay@amd.com> X-Mailman-Approved-At: Thu, 10 Jul 2014 16:33:12 -0700 Cc: Andrew Lewycky , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Oded Gabbay --- drivers/gpu/hsa/radeon/kfd_device.c | 3 +++ drivers/gpu/hsa/radeon/kfd_device_queue_manager.c | 2 +- drivers/gpu/hsa/radeon/kfd_mqd_manager.c | 1 + drivers/gpu/hsa/radeon/kfd_packet_manager.c | 3 ++- drivers/gpu/hsa/radeon/kfd_process.c | 10 ++++++---- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/hsa/radeon/kfd_device.c b/drivers/gpu/hsa/radeon/kfd_device.c index 9af812b..30558c9 100644 --- a/drivers/gpu/hsa/radeon/kfd_device.c +++ b/drivers/gpu/hsa/radeon/kfd_device.c @@ -88,6 +88,9 @@ struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev) return NULL; kfd = kzalloc(sizeof(*kfd), GFP_KERNEL); + if (!kfd) + return NULL; + kfd->kgd = kgd; kfd->device_info = device_info; kfd->pdev = pdev; diff --git a/drivers/gpu/hsa/radeon/kfd_device_queue_manager.c b/drivers/gpu/hsa/radeon/kfd_device_queue_manager.c index 56875f9..4931f8a 100644 --- a/drivers/gpu/hsa/radeon/kfd_device_queue_manager.c +++ b/drivers/gpu/hsa/radeon/kfd_device_queue_manager.c @@ -317,7 +317,7 @@ static struct mqd_manager *get_mqd_manager_nocpsch(struct device_queue_manager * { struct mqd_manager *mqd; - BUG_ON(!dqm || type > KFD_MQD_TYPE_MAX); + BUG_ON(!dqm || type >= KFD_MQD_TYPE_MAX); pr_debug("kfd: In func %s mqd type %d\n", __func__, type); diff --git a/drivers/gpu/hsa/radeon/kfd_mqd_manager.c b/drivers/gpu/hsa/radeon/kfd_mqd_manager.c index a3e9f7c..8c1192e 100644 --- a/drivers/gpu/hsa/radeon/kfd_mqd_manager.c +++ b/drivers/gpu/hsa/radeon/kfd_mqd_manager.c @@ -437,6 +437,7 @@ struct mqd_manager *mqd_manager_init(enum KFD_MQD_TYPE type, struct kfd_dev *dev mqd->uninitialize = uninitialize; break; default: + kfree(mqd); return NULL; break; } diff --git a/drivers/gpu/hsa/radeon/kfd_packet_manager.c b/drivers/gpu/hsa/radeon/kfd_packet_manager.c index 621a720..5cd23b0 100644 --- a/drivers/gpu/hsa/radeon/kfd_packet_manager.c +++ b/drivers/gpu/hsa/radeon/kfd_packet_manager.c @@ -85,9 +85,10 @@ static int pm_allocate_runlist_ib(struct packet_manager *pm, unsigned int **rl_b BUG_ON(!pm); BUG_ON(pm->allocated == true); + BUG_ON(is_over_subscription == NULL); pm_calc_rlib_size(pm, rl_buffer_size, is_over_subscription); - if (is_over_subscription && + if (*is_over_subscription && sched_policy == KFD_SCHED_POLICY_HWS_NO_OVERSUBSCRIPTION) return -EFAULT; diff --git a/drivers/gpu/hsa/radeon/kfd_process.c b/drivers/gpu/hsa/radeon/kfd_process.c index eb30cb3..aacc7ef 100644 --- a/drivers/gpu/hsa/radeon/kfd_process.c +++ b/drivers/gpu/hsa/radeon/kfd_process.c @@ -146,15 +146,15 @@ static struct kfd_process *create_process(const struct task_struct *thread) process = kzalloc(sizeof(*process), GFP_KERNEL); if (!process) - goto err_alloc; + goto err_alloc_process; process->queues = kmalloc_array(INITIAL_QUEUE_ARRAY_SIZE, sizeof(process->queues[0]), GFP_KERNEL); if (!process->queues) - goto err_alloc; + goto err_alloc_queues; process->pasid = radeon_kfd_pasid_alloc(); if (process->pasid == 0) - goto err_alloc; + goto err_alloc_pasid; mutex_init(&process->mutex); @@ -178,9 +178,11 @@ err_process_pqm_init: radeon_kfd_pasid_free(process->pasid); list_del(&process->processes_list); thread->mm->kfd_process = NULL; -err_alloc: +err_alloc_pasid: kfree(process->queues); +err_alloc_queues: kfree(process); +err_alloc_process: return ERR_PTR(err); }