Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp116475imm; Tue, 3 Jul 2018 15:08:27 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKniSoTfB/HfqCSSHsrSJJF8VrJP9PELwrpupducX/kepVvdV9ia4uYJwAml/LgpFioP6nt X-Received: by 2002:a17:902:6e09:: with SMTP id u9-v6mr31029180plk.13.1530655707179; Tue, 03 Jul 2018 15:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530655707; cv=none; d=google.com; s=arc-20160816; b=ei/moPdlLB+uNdbvnU74NhBZx4LRBMMsbxY8sNGgf8aawU/KAFFL15j389C7x+hwKZ zroJtnGeCRQ5WQwZEjw/mz08PE3xZsdNus6uU1Mbqiq+sRYXvKZxN+OrNMTTrYxTR2i1 IGUJxGihDDTqRjFCebnT5/8RPTv5z0kgt2j1jez7NHOQ7msW6bWixxlnnGAWmyKGbEtF gMVSB2pzJOhnn3jtsYT7gc8uJAHjqDvz4Nu/VOR8lqqXY/xns+S/4fewKDtQJsp7ovzP d8jFZm1rcChAPSr0hL1du9z0bgNg2cL3XDcblwWDrMiZZAk/RAXQpnJ8B2XNwaZUn2YV 8LZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=ZVgeIv+UXteYNXUJvX5XdBokyLNGelnIvxFUTrKc/xI=; b=Wm6uV0U+5xno3YHGiu8qdYxpUajdCy0fqkeIABVvSgtuIUAnCjetMySXAOaXC1BKaN +0xiIE2Ex4lvg3YVqAGDbsowrbVpHTxTbLEMESYteB4ZT/oKUHkfSID4ERzWPk9ORhQc nUlonRQNSXFa/1OFrCA6I6arQ0mnVMsO3ZZThQK6/NOQMTXQQAheHZdeiuHa/S1u4/yp chKnofmBQ38KTCLcpqN70EPaKjIQfh4G9WqhIlbTeTlYGp0QV+OS9zYEvWS8TxuCYuOX NKHwNa3uD32de8aDaFzXn5LFrPJN5NAaHw9e4TYF3kD7u8aseJv498prjfD3CnsX6KYL OBtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l81-v6si2106097pfa.368.2018.07.03.15.08.12; Tue, 03 Jul 2018 15:08:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933692AbeGCWGK (ORCPT + 99 others); Tue, 3 Jul 2018 18:06:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45696 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933673AbeGCWGH (ORCPT ); Tue, 3 Jul 2018 18:06:07 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0156F81A4EB9; Tue, 3 Jul 2018 22:06:07 +0000 (UTC) Received: from malachite.bss.redhat.com (dhcp-10-20-1-11.bss.redhat.com [10.20.1.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id BA2C4FF5B; Tue, 3 Jul 2018 22:06:06 +0000 (UTC) From: Lyude Paul To: nouveau@lists.freedesktop.org Cc: stable@vger.kernel.org, Ben Skeggs , David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] drm/nouveau: Fix runtime PM leak in drm_open() Date: Tue, 3 Jul 2018 18:05:59 -0400 Message-Id: <20180703220602.16664-2-lyude@redhat.com> In-Reply-To: <20180703220602.16664-1-lyude@redhat.com> References: <20180703220602.16664-1-lyude@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 03 Jul 2018 22:06:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Tue, 03 Jul 2018 22:06:07 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lyude@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Noticed this as I was skimming through, if we fail to allocate memory for cli we'll end up returning without dropping the runtime PM ref we got. Additionally, we'll even return the wrong return code! (ret most likely will == 0 here, we want -ENOMEM). Signed-off-by: Lyude Paul Cc: stable@vger.kernel.org --- drivers/gpu/drm/nouveau/nouveau_drm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 0452b18d36b9..0f668e275ee1 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -919,8 +919,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) get_task_comm(tmpname, current); snprintf(name, sizeof(name), "%s[%d]", tmpname, pid_nr(fpriv->pid)); - if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) - return ret; + if (!(cli = kzalloc(sizeof(*cli), GFP_KERNEL))) { + ret = -ENOMEM; + goto done; + } ret = nouveau_cli_init(drm, name, cli); if (ret) -- 2.17.1