From patchwork Thu Feb 4 23:17:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Insu Yun X-Patchwork-Id: 8229421 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C6E0DBEEE5 for ; Thu, 4 Feb 2016 23:57:12 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C55E4203A9 for ; Thu, 4 Feb 2016 23:57:11 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 419402039C for ; Thu, 4 Feb 2016 23:57:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF19E6E15D; Thu, 4 Feb 2016 15:57:07 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-yk0-f179.google.com (mail-yk0-f179.google.com [209.85.160.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id B92BA6E159 for ; Thu, 4 Feb 2016 15:17:48 -0800 (PST) Received: by mail-yk0-f179.google.com with SMTP id r207so52485820ykd.2 for ; Thu, 04 Feb 2016 15:17:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=oE9kvq8KhbEGfS7T+NJsWU+fBoiJ0IO7/9zKOccEIro=; b=NIdzBm1h9Vs6HNO1uU8U0SJw7FcTlEbS0XwbvACAUnJvCjAJSawAtXLxWQ6vDOzmvD 8hnkEhHJK5XAh7NVnm3a9dNLP6iE+5JeuQNCEhuznK8FMqFdKn393LP5WMFwpE8itJ42 U6REVTWz/0lLQsQJZ35M25evzPCptjyCNEyz9pF8FDKZL+csfriGA0+9hCrVKKhSMoQ8 FIZpjch4/QTytuE3lg6lqh5kkYXf/wwbVIHk5gEE38b6OWLu9zW2eHEvvIxWEJ52WoQq d2D4+trxF+Ga3Xhm8vzDjXopwqH5PlywbSGaHOFhG0LWZqo13z66zIJAFNOx4+Z20Q8J Q1yw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=oE9kvq8KhbEGfS7T+NJsWU+fBoiJ0IO7/9zKOccEIro=; b=FgIKKSiSfHiRexequTFn67Z6jZeTqSC5crhzl51r2m6oO4ood30lASlqYg/0sOmPwo Xpw/SUj515uYwg7x6wWqXJjGYqDJv8Os5OMuGchIQwbmJ0RFV0qu525qg9LExtFsmkbr kkTEEOTTqWmaf0XeBZ3xzg0M6uP8DRig72sJvs6cSYR4EnRwAvphK3Gh2+9q/z4H4+1g TQ45DfPdySGGwTa5bPyT5gyazXC1UWmJbfZp4NnC7QorGYdig7iAdzt9aQ50OivDxNdK N5fuDpDW0t3nznAmDFg4mzsnjuok4Bw+evfARWLP3eo2rRcFCSHLuOpfUC7E2vmCLPWy XgCg== X-Gm-Message-State: AG10YOT/8Op1g8L0gskW1LQKO+U7ggdWkReK8C0WX/gu1BBRSZQov8PQQxWXZx2CFa3Nbg== X-Received: by 10.129.133.193 with SMTP id v184mr5843334ywf.262.1454627867914; Thu, 04 Feb 2016 15:17:47 -0800 (PST) Received: from insu.gtisc.gatech.edu (insu.gtisc.gatech.edu. [143.215.130.94]) by smtp.gmail.com with ESMTPSA id a205sm8766041ywe.50.2016.02.04.15.17.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Feb 2016 15:17:47 -0800 (PST) From: Insu Yun To: airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] qxl: handling failed allocation Date: Thu, 4 Feb 2016 18:17:53 -0500 Message-Id: <1454627873-26358-1-git-send-email-wuninsu@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Thu, 04 Feb 2016 15:57:06 -0800 Cc: yeongjin.jang@gatech.edu, taesoo@gatech.edu, insu@gatech.edu, Insu Yun , changwoo@gatech.edu X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 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.5 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, 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 Since kmalloc can be failed in memory pressure, check and return error code otherwise NULL deference could be happened Signed-off-by: Insu Yun --- drivers/gpu/drm/qxl/qxl_kms.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c index b2977a1..02d26b3 100644 --- a/drivers/gpu/drm/qxl/qxl_kms.c +++ b/drivers/gpu/drm/qxl/qxl_kms.c @@ -221,6 +221,9 @@ static int qxl_device_init(struct qxl_device *qdev, kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot), GFP_KERNEL); + if (!qdev->mem_slots) + return -ENOMEM; + idr_init(&qdev->release_idr); spin_lock_init(&qdev->release_idr_lock); spin_lock_init(&qdev->release_lock);