From patchwork Wed Sep 21 14:59:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Gundersen X-Patchwork-Id: 9343715 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A24F86077A for ; Wed, 21 Sep 2016 15:12:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 978B92A3B1 for ; Wed, 21 Sep 2016 15:12:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C7F42A6F5; Wed, 21 Sep 2016 15:12:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2CFFD2A3B1 for ; Wed, 21 Sep 2016 15:12:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D1C7C6E854; Wed, 21 Sep 2016 15:12:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id DA28F6E852 for ; Wed, 21 Sep 2016 15:10:13 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id b71so1784181lfg.1 for ; Wed, 21 Sep 2016 08:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jklm-no.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=oaSvl1n9FHgAa4yFxVVkGtZx1A30L9SLsK+TgkxZPeI=; b=tpHS1YpBjx8WdLcH60qg8vYgk7bGdJuhCSi/KG8DGgUr+ICSdYdidD7Zn08WGmjLjo M3iiCCuxEkhuBBGAaBq2IkjCXi5PmT/+abtB4sJxEKd5IFmOcLiaeXPdN+XFkeJmKFCx 2yZl7s21zIySIeVCB0UTd4lWgxq32BKTRORwKne00SuurQlkcFe+Z9FJQNKcvfblLK9n wmTWquUXtIxD367KyoA6EetPX0EOz9UlSJZVW9zX3h4eGtDqz4l/F1FV0M8I3lBuVgoQ VoruSj5eXa/X414IVmPYp0n2h6DrbJ80Yd7UtE2MjVnNNw8NaBXtr3FHMV/WryeNWJFv gZCA== 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=oaSvl1n9FHgAa4yFxVVkGtZx1A30L9SLsK+TgkxZPeI=; b=VCLFgWH5N6Y7WtY5syWCu4VWNXNoFj4+Jr/fvs/GNu+ejVW5n5YHsuGap4PdnUJeH+ 3Wmk0ZBs0N25w5y74fEnUcXLu2y0RcaYQ0Z6yE8ppOftxuXBTPj1sZl+k1zZS9Nv19X1 Uvv5qXrLHxYf9TEaqJc4iMf6AHhW97UgVI+gHgXV+RShvwR0ykmxkYbqQyNyzPnWUxNb JY1xYHSt0jRt4YFW3Pw/IowIG8XuRv8YnGZffcGbZGHUiLUjsc9YC9VV+C4c5NLHb6fJ n7ZvQaXHNgdYIw8dB4W/WWnN4V4wce69ArYOsII/MoLauD1WK1uO3OFAvotcBYojhgLW jq7A== X-Gm-Message-State: AE9vXwP5PvHp9cB0aEZmFH2gcdH+S1q66fS1cHOGO9y1s9EQzZgCQq77m/HU+gPbXUP80g== X-Received: by 10.25.40.74 with SMTP id o71mr15405490lfo.36.1474470611705; Wed, 21 Sep 2016 08:10:11 -0700 (PDT) Received: from localhost.localdomain ([2a02:fe0:c130:1430:7e7a:91ff:fe0e:3e2c]) by smtp.gmail.com with ESMTPSA id 202sm6905496ljf.33.2016.09.21.08.10.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Sep 2016 08:10:10 -0700 (PDT) From: Tom Gundersen To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: Distinguish no name from ENOMEM in set_unique() Date: Wed, 21 Sep 2016 16:59:18 +0200 Message-Id: <20160921145919.13754-1-teg@jklm.no> X-Mailer: git-send-email 2.9.3 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-Virus-Scanned: ClamAV using ClamSMTP If passing name == NULL to drm_drv_set_unique() we now get -ENOMEM as kstrdup() returns NULL. Instead check for this explicitly and return -EINVAL if no name is provided. Signed-off-by: Tom Gundersen Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_drv.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index f2f6429..99e6751 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -338,6 +338,9 @@ void drm_minor_release(struct drm_minor *minor) static int drm_dev_set_unique(struct drm_device *dev, const char *name) { + if (!name) + return -EINVAL; + kfree(dev->unique); dev->unique = kstrdup(name, GFP_KERNEL);