From patchwork Tue Jul 7 08:14:34 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudip Mukherjee X-Patchwork-Id: 6730941 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2E1629F319 for ; Tue, 7 Jul 2015 08:15:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 733942072E for ; Tue, 7 Jul 2015 08:15:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FE9E20719 for ; Tue, 7 Jul 2015 08:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756405AbbGGIPG (ORCPT ); Tue, 7 Jul 2015 04:15:06 -0400 Received: from mail-pd0-f171.google.com ([209.85.192.171]:36612 "EHLO mail-pd0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756256AbbGGIO6 (ORCPT ); Tue, 7 Jul 2015 04:14:58 -0400 Received: by pddu5 with SMTP id u5so34082038pdd.3; Tue, 07 Jul 2015 01:14:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qdayj0k/rZoU5xHQhmbbYdyFJ7onaBBu0nGn9xsomNE=; b=NME6C9qEiJ5XHToP2pNK42IqvzWBjVmPhb46Krovh1PSYccGObGAf0kzau9O1xgS3B 8W6BYVphX0QRThnRGaOcphsAHl/PEaPWPraDyHgD5Z5LOm3L9QjM9uXMpfSxV4nGtvFQ UWad1IGCw/UhshVRVCJuQkudyBI3+QWlI2d4kegXjWPtTxGGp30FkQt/BwlZzOZQb12j BEtekpBtaHikz6PmlTx8EtmP5m3cG17u392a2v+g0RnGWDPEuAP5bYxSfaEmsjwhvD3c 89dovhboy8byYDmUeTwPzqhcldz86Qehxcnl1T5RISLBqFhuTJlWzJ55rSF9Be7qBcrw Iryw== X-Received: by 10.66.150.169 with SMTP id uj9mr6239660pab.125.1436256897448; Tue, 07 Jul 2015 01:14:57 -0700 (PDT) Received: from localhost.localdomain ([49.206.254.91]) by mx.google.com with ESMTPSA id wm8sm20823418pbc.19.2015.07.07.01.14.54 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 07 Jul 2015 01:14:56 -0700 (PDT) From: Sudip Mukherjee To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-fbdev@vger.kernel.org, devel@driverdev.osuosl.org, Dan Carpenter , Sudip Mukherjee Subject: [PATCH 2/5] staging: sm7xxfb: fix error handling Date: Tue, 7 Jul 2015 13:44:34 +0530 Message-Id: <1436256877-10754-3-git-send-email-sudipm.mukherjee@gmail.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1436256877-10754-1-git-send-email-sudipm.mukherjee@gmail.com> References: <1436256877-10754-1-git-send-email-sudipm.mukherjee@gmail.com> Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We were checking smtc_regbaseaddress and that too at a place where it can never be NULL. Real check should be on sfb->lfb immediately after we do ioremap. Signed-off-by: Sudip Mukherjee --- drivers/staging/sm7xxfb/sm7xxfb.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c index 2ff4fe7..8fb62af 100644 --- a/drivers/staging/sm7xxfb/sm7xxfb.c +++ b/drivers/staging/sm7xxfb/sm7xxfb.c @@ -1456,6 +1456,14 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, #else sfb->lfb = ioremap(mmio_base, 0x00800000); #endif + if (!sfb->lfb) { + dev_err(&pdev->dev, + "%s: unable to map memory mapped IO!\n", + sfb->fb->fix.id); + err = -ENOMEM; + goto failed_fb; + } + sfb->mmio = (smtc_regbaseaddress = sfb->lfb + 0x00700000); sfb->dp_regs = sfb->lfb + 0x00408000; @@ -1466,13 +1474,6 @@ static int smtcfb_pci_probe(struct pci_dev *pdev, dev_info(&pdev->dev, "sfb->lfb=%p\n", sfb->lfb); } #endif - if (!smtc_regbaseaddress) { - dev_err(&pdev->dev, - "%s: unable to map memory mapped IO!\n", - sfb->fb->fix.id); - err = -ENOMEM; - goto failed_fb; - } /* set MCLK = 14.31818 * (0x16 / 0x2) */ smtc_seqw(0x6a, 0x16);