From patchwork Sun Jun 24 15:38:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Mack X-Patchwork-Id: 10484685 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 84344603B5 for ; Sun, 24 Jun 2018 16:06:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 699232882C for ; Sun, 24 Jun 2018 16:06:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E70E28878; Sun, 24 Jun 2018 16:06:57 +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=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E3072882C for ; Sun, 24 Jun 2018 16:06:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755741AbeFXPia (ORCPT ); Sun, 24 Jun 2018 11:38:30 -0400 Received: from mail.bugwerft.de ([46.23.86.59]:50622 "EHLO mail.bugwerft.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755394AbeFXPi2 (ORCPT ); Sun, 24 Jun 2018 11:38:28 -0400 Received: from localhost.localdomain (pD95EF54E.dip0.t-ipconnect.de [217.94.245.78]) by mail.bugwerft.de (Postfix) with ESMTPSA id 4166128B19E; Sun, 24 Jun 2018 15:35:16 +0000 (UTC) From: Daniel Mack To: b.zolnierkie@samsung.com, tomi.valkeinen@ti.com Cc: linux-fbdev@vger.kernel.org, robert.jarzmik@free.fr, Daniel Mack Subject: [PATCH 3/4] video: fbdev: pxafb: handle errors from pxafb_init_fbinfo() correctly Date: Sun, 24 Jun 2018 17:38:16 +0200 Message-Id: <20180624153817.24387-3-daniel@zonque.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180624153817.24387-1-daniel@zonque.org> References: <20180624153817.24387-1-daniel@zonque.org> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP pxafb_init_fbinfo() can not only report errors caused by failed allocations but also when the clock can't be found. To fix this, return an error pointer instead of NULL in case of errors, and up-chain the result. Signed-off-by: Daniel Mack Reviewed-by: Robert Jarzmik --- drivers/video/fbdev/pxafb.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/video/fbdev/pxafb.c b/drivers/video/fbdev/pxafb.c index 6f3a93b3097c..68459b07d442 100644 --- a/drivers/video/fbdev/pxafb.c +++ b/drivers/video/fbdev/pxafb.c @@ -1802,14 +1802,14 @@ static struct pxafb_info *pxafb_init_fbinfo(struct device *dev, fbi = devm_kzalloc(dev, sizeof(struct pxafb_info) + sizeof(u32) * 16, GFP_KERNEL); if (!fbi) - return NULL; + return ERR_PTR(-ENOMEM); fbi->dev = dev; fbi->inf = inf; fbi->clk = devm_clk_get(dev, NULL); if (IS_ERR(fbi->clk)) - return NULL; + return ERR_CAST(fbi->clk); strcpy(fbi->fb.fix.id, PXA_NAME); @@ -2287,10 +2287,9 @@ static int pxafb_probe(struct platform_device *dev) } fbi = pxafb_init_fbinfo(&dev->dev, inf); - if (!fbi) { - /* only reason for pxafb_init_fbinfo to fail is kmalloc */ + if (IS_ERR(fbi)) { dev_err(&dev->dev, "Failed to initialize framebuffer device\n"); - ret = -ENOMEM; + ret = PTR_ERR(fbi); goto failed; }