Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp649081imu; Fri, 11 Jan 2019 06:47:35 -0800 (PST) X-Google-Smtp-Source: ALg8bN7ITBS7CHXldy1D5XHwuUszlviDp3DkStHjwHFzOAMmxqCAy7wtSbz2F0s7eNES/6O6oNrL X-Received: by 2002:a17:902:a5ca:: with SMTP id t10mr14869411plq.139.1547218055004; Fri, 11 Jan 2019 06:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547218054; cv=none; d=google.com; s=arc-20160816; b=GX92iWwFg8JZmuBJsv6sjXvQjAoI1TfsqW+lucPi/hWzzk7h4gfpjCnPQsqdXgk1zQ 3A2vB4XkEyYTiICR08Q1RaGAW4WJmbrj/Co1B8sdNVHudO5DhlObpst98MduQkCApz+X NMd4vIbALlOfosgKwLgjUODPkeUYtJVotXnoKG5fZaPz/rUV80ZwCP7QDQ4bbrDw/xQ/ D54dlAw2HhZmyFFh28XzfK6hOj33DJ+UAVh3xCjdiKSXfWZz0/MSDICMJH6sy6KKyr5c 2jio8JYm4kx863xa5DHR1PzAkv1NW8Ke4Vd9rRDY29L08hEfLuv+l4TDGGyCy6JznWJ0 s5lQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=mXDu4ayF3n+BrEgbkPFiRMxTPuJ+UNM5C1cDrMcJNwM=; b=MlH12KPY37AikuHZxYTW4SFJtewIXWLDe/eo+p5gM5Xx8eliKe4JDtKOeJ38zuBZ3A tEMrWC5S50R5de2/gURAaR0b8fUv0XYj9nZku3OyGl4ChwC39SR+64RkkKfWjqcM4pba I7jvm9b2g8wFh2jRyAZ1RSN03G8ZlRvwQLmvCFXG8XmfBO2l69B34ScqJaKwVmd9km4D o1I0pnwwMhRN7d54+vi0PfjrK5s/0HjumEUPyU1797YmX3Wk9evqsvFbw5pEXdo50TRO I6arwoB6K8nmLB4R0Wtr0kPEurAX/mLlCmzhykJhjls7fBGN+xlD1j/ojGURYFBFyVkG MsJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=d4qE47ed; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si13083714ply.409.2019.01.11.06.47.19; Fri, 11 Jan 2019 06:47:34 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=d4qE47ed; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404587AbfAKOoT (ORCPT + 99 others); Fri, 11 Jan 2019 09:44:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:37250 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404563AbfAKOoR (ORCPT ); Fri, 11 Jan 2019 09:44:17 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 63FB820872; Fri, 11 Jan 2019 14:44:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547217856; bh=wa//pIZjnta58CNe8jdud9BG4a+cvFT5+781LrmEcao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d4qE47edAh+mgw5XMD21c/fo1Ov1x2BomWpnOwO7CQHFWOioKOj9+YA2OkeOf7oNm uRuOuUB1WVQNZ24TxyGNm2LxkWlIvTovRQ4GrRJFU3Jn+sKjWQfLVeMh5amic+Tqr1 Y/WeztttVHuNLGOKkluSq8TfGbpEC0LrB08VDdUk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Enric Balletbo i Serra , Heiko Stuebner Subject: [PATCH 4.20 65/65] drm/rockchip: psr: do not dereference encoder before it is null checked. Date: Fri, 11 Jan 2019 15:15:51 +0100 Message-Id: <20190111131104.575512035@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190111131055.331350141@linuxfoundation.org> References: <20190111131055.331350141@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ From: Enric Balletbo i Serra commit 4eda776c3cefcb1f01b2d85bd8753f67606282b5 upstream. 'encoder' is dereferenced before it is null sanity checked, hence we potentially have a null pointer dereference bug. Instead, initialise drm_drv from encoder->dev->dev_private after we are sure 'encoder' is not null. Fixes: 5182c1a556d7f ("drm/rockchip: add an common abstracted PSR driver") Cc: stable@vger.kernel.org Signed-off-by: Enric Balletbo i Serra Signed-off-by: Heiko Stuebner Link: https://patchwork.freedesktop.org/patch/msgid/20181013105654.11827-1-enric.balletbo@collabora.com Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/rockchip/rockchip_drm_psr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/rockchip/rockchip_drm_psr.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_psr.c @@ -189,12 +189,14 @@ EXPORT_SYMBOL(rockchip_drm_psr_flush_all int rockchip_drm_psr_register(struct drm_encoder *encoder, int (*psr_set)(struct drm_encoder *, bool enable)) { - struct rockchip_drm_private *drm_drv = encoder->dev->dev_private; + struct rockchip_drm_private *drm_drv; struct psr_drv *psr; if (!encoder || !psr_set) return -EINVAL; + drm_drv = encoder->dev->dev_private; + psr = kzalloc(sizeof(struct psr_drv), GFP_KERNEL); if (!psr) return -ENOMEM;