Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2037274imm; Mon, 16 Jul 2018 00:37:10 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf1FDVvbGXR4cHft7p3wZxUIDhzN4qgejbAPXCmCPNWL/8EriLqAf0P2VavZPAlzTHzTf8Q X-Received: by 2002:a63:195e:: with SMTP id 30-v6mr14314475pgz.192.1531726630054; Mon, 16 Jul 2018 00:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531726630; cv=none; d=google.com; s=arc-20160816; b=c5fmzth+inP4pLMzPZczQ+MERC1q4jfNBwbRue0zZbIbLC+h/QAFbZdYhTmMGvawt4 nyTRuKHJcPqFnKRlz8CmNKKP7hzT9BJ6RZN5mimEUiJ9Y0aAFzwRdoBoiaXG9DBnoGLV yC6Y9u8YvjpmKdfZIyS7KjE4+crP0B0b1rkMX0AgmRZHr2lTzL2Uy4uyuE75SWZ4pK7J d4vxCX3FOpomOjWBTS/UmEEIQAjaP2V9m8O3ydYX8rMELZVhzripVY6BC+MQD7wPIX1t N/98ms7bkfCgBWhsQ6h0Ve+9kYncTT00uG3YkwDdbjaK6MTfHIy55r152dkupOPUq1d1 o44A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iNKN0+b5G2nxsHoDGDxY+6bm1sU8RK5jbsAFZFOZXDg=; b=kX6SaeG3mGKOEe6wgBVti+H4Hz2e43KDaEEG5sBRDBx0dssJY+SM3HL0wTWvB+7XJD TG7+sEpEnP6CndnNrGTri9Ba7sVSUnkSRzQHJk4JYVr/qDWQnlvMQXcvMEU0vSnIKRrp fVwMA7psxiJzTg0kgySnLq1YYriyeO8ew/gyjUG6nDdwMWzumaa1Qp4aPtZV7+VQlua3 GshNIYvUCTM8X8h7nDil2w7p5J7RiND9vqEsLceFGkpuz9JtKhqeiwK6nj47Er84Xe7A XmOxFZv2A8Bli1YjGk85McfPwJ9N/DFZaa4NdreAuHCdO/q5nZK9q2DaIGjkgNZKiqez AbDg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9-v6si29144219plt.232.2018.07.16.00.36.42; Mon, 16 Jul 2018 00:37:10 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730810AbeGPIB7 (ORCPT + 99 others); Mon, 16 Jul 2018 04:01:59 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46576 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730092AbeGPIB7 (ORCPT ); Mon, 16 Jul 2018 04:01:59 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 739F1CAF; Mon, 16 Jul 2018 07:35:58 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Fabio Estevam , Philipp Zabel , Lucas Stach Subject: [PATCH 4.17 05/67] drm/etnaviv: Check for platform_device_register_simple() failure Date: Mon, 16 Jul 2018 09:34:34 +0200 Message-Id: <20180716073443.982040755@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073443.294323458@linuxfoundation.org> References: <20180716073443.294323458@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fabio Estevam commit 45a0faaba9c8c5ba1e31a08a391aed0bad327167 upstream. platform_device_register_simple() may fail, so we should better check its return value and propagate it in the case of error. Cc: Fixes: 246774d17fc0 ("drm/etnaviv: remove the need for a gpu-subsystem DT node") Signed-off-by: Fabio Estevam Reviewed-by: Philipp Zabel Signed-off-by: Lucas Stach Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/etnaviv/etnaviv_drv.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c @@ -693,8 +693,11 @@ static struct platform_driver etnaviv_pl }, }; +static struct platform_device *etnaviv_drm; + static int __init etnaviv_init(void) { + struct platform_device *pdev; int ret; struct device_node *np; @@ -706,7 +709,7 @@ static int __init etnaviv_init(void) ret = platform_driver_register(&etnaviv_platform_driver); if (ret != 0) - platform_driver_unregister(&etnaviv_gpu_driver); + goto unregister_gpu_driver; /* * If the DT contains at least one available GPU device, instantiate @@ -715,12 +718,24 @@ static int __init etnaviv_init(void) for_each_compatible_node(np, NULL, "vivante,gc") { if (!of_device_is_available(np)) continue; - - platform_device_register_simple("etnaviv", -1, NULL, 0); + pdev = platform_device_register_simple("etnaviv", -1, + NULL, 0); + if (IS_ERR(pdev)) { + ret = PTR_ERR(pdev); + of_node_put(np); + goto unregister_platform_driver; + } + etnaviv_drm = pdev; of_node_put(np); break; } + return 0; + +unregister_platform_driver: + platform_driver_unregister(&etnaviv_platform_driver); +unregister_gpu_driver: + platform_driver_unregister(&etnaviv_gpu_driver); return ret; } module_init(etnaviv_init);