From patchwork Tue Jun 23 19:55:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.0 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 318C1C433E0 for ; Tue, 23 Jun 2020 21:16:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00EAC20702 for ; Tue, 23 Jun 2020 21:16:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592946986; bh=Qm2d/tMU5SizH6un6knnDQpfNtVPUrE8jVQCZ+MR8WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=UJPcDiqftq+aqn5p0KuepJwJ9GIqEM+54Of64H0O5/5jlnp0/Yh0Qlael/T2iQPRP y2mDsp3ys1eoKdvftYp0XPlME0MfC3tHXaItr901Jq+Vxyi3nX4zfvck69HYbnMFMJ 8VYsxweOJL2nae+GxRZmyxCVGtv9jtF4KO3Ttydo= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390774AbgFWU1f (ORCPT ); Tue, 23 Jun 2020 16:27:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:47144 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390771AbgFWU1f (ORCPT ); Tue, 23 Jun 2020 16:27:35 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.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 4EE7F20702; Tue, 23 Jun 2020 20:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592944054; bh=Qm2d/tMU5SizH6un6knnDQpfNtVPUrE8jVQCZ+MR8WM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jcF8RDXpA7B3xRnSIfmWcspfWLC/QodpV9jmmXbGt5Y2cqM8ccQTeADur/KRyRFMZ ST7wMtGncSTYxRvICZH4HOjAjakSuFnTZLIuJDM4gJwq6Mg5SXop3TGvREOx4dcLwc ZqmmUj88wcHrSISqrf69mCuVkf8H5mIvT1/km+gg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roy Spliet , Abhinav Kumar , Rob Clark , Sasha Levin Subject: [PATCH 5.4 154/314] drm/msm/mdp5: Fix mdp5_init error path for failed mdp5_kms allocation Date: Tue, 23 Jun 2020 21:55:49 +0200 Message-Id: <20200623195346.202507110@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200623195338.770401005@linuxfoundation.org> References: <20200623195338.770401005@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Roy Spliet [ Upstream commit e4337877c5d578722c0716f131fb774522013cf5 ] When allocation for mdp5_kms fails, calling mdp5_destroy() leads to undefined behaviour, likely a nullptr exception or use-after-free troubles. Signed-off-by: Roy Spliet Reviewed-by: Abhinav Kumar Signed-off-by: Rob Clark Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c index 91cd76a2bab11..77823ccdd0f8f 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c @@ -1037,7 +1037,8 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev) return 0; fail: - mdp5_destroy(pdev); + if (mdp5_kms) + mdp5_destroy(pdev); return ret; }