From patchwork Tue May 7 19:43:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Moritz Fischer X-Patchwork-Id: 10933721 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1235C14B6 for ; Tue, 7 May 2019 19:43:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0095620602 for ; Tue, 7 May 2019 19:43:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E70D82857F; Tue, 7 May 2019 19:43:35 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9A94920602 for ; Tue, 7 May 2019 19:43:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=zxBDlKO66ZdRt1qVWtzGwl8JqcgDh4yZSVObnZy5XGQ=; b=dy6Kc1jNvclV6k CNaQ+TIhC7fSHM7H5EOTYTxs6hf2+9UdlGRYO4Tu7E3xEkQfniO7HdXDiVz9z2S14h9oBGaSjXExz DDKIlTupbAOFyp2KfHi914SfLbT35Z8KAp5zjAXPLFqRmJ37a9fZlg0cjVnBT3PCINE3PWCYVBNVN B8IDpPIw+U5ELEWdYmntGiITUrOfZTEmL+KhN6EmXwR9Z4o9mU+pHBRR7tmnGlCsYTjz20BI8OhoH S4+n+agQb4KsW95BUHzTS0AlfgbumqCDoddzVKCo/Wdl8yINe0IvkeuF15UGaPW8t9tWZCTnxxRD8 sdvGJEecyWv3KQY8IarA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hO5zy-0007zj-Rt; Tue, 07 May 2019 19:43:34 +0000 Received: from mail-pf1-f193.google.com ([209.85.210.193]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hO5zw-0007zQ-7C for linux-arm-kernel@lists.infradead.org; Tue, 07 May 2019 19:43:33 +0000 Received: by mail-pf1-f193.google.com with SMTP id l132so4228342pfc.8 for ; Tue, 07 May 2019 12:43:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ewkuTpRG7XAqOKCyoArod5p1Qyn37L7LNzmlcvLqB88=; b=sAOz+dGLjq/tmb+wMgRZkE1tuZZWFILOWpaLhX6t17gbKwc7vBvkNdJ42C1hFV1psz YGCSBCYkkFJyvH7lMI7Y4n39RuhQWOfXjH+nB4yT+SDk+6MEZYPbBfactiwtG8CfsmQk JRob1yC39j8HxcxUFRV9IEuYtkhGQSTzXcY0ygUAJd0U0yzp3Faol4B8vf/QSzOLUQy7 X0jD39UDrehgVKUVenEJFzgDOv1/jBmSui1JYCGuUFQkcS/e5kzFo2ea6qZRC7SRQUds VE46+B+CnoupSSTHrhlehhTuW82UXU2+dY717CFmLfrNGsaMmQazZl37KTrIFsvNoCBw pKSQ== X-Gm-Message-State: APjAAAUNbErNYOn/SUyc5kp4BP5tEEfWOpvqJ0yR6Q37vgFOqPYUYol/ S08U3dPuYj5rOZ8l/42dYian4A== X-Google-Smtp-Source: APXvYqzBkEu3Inaaw5RJcp14jDR73QiaQstLX9sXE/2auF/4QH+BQhdInVPnwxoNgO9g7hlwJL4HxQ== X-Received: by 2002:a62:e50a:: with SMTP id n10mr43912680pff.55.1557258210936; Tue, 07 May 2019 12:43:30 -0700 (PDT) Received: from localhost ([2601:647:4700:2953:ec49:968:583:9f8]) by smtp.gmail.com with ESMTPSA id s79sm31216845pfa.31.2019.05.07.12.43.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 May 2019 12:43:29 -0700 (PDT) From: Moritz Fischer To: linux-fpga@vger.kernel.org Subject: [PATCH v2] fpga: zynqmp-fpga: Correctly handle error pointer Date: Tue, 7 May 2019 12:43:13 -0700 Message-Id: <20190507194313.1618-1-mdf@kernel.org> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190507_124332_270043_AF075D65 X-CRM114-Status: GOOD ( 11.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: atull@kernel.org, michal.simek@xilinx.com, linux-kernel@vger.kernel.org, Moritz Fischer , linux-arm-kernel@lists.infradead.org, Dan Carpenter Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Fixes the following static checker errors: drivers/fpga/zynqmp-fpga.c:50 zynqmp_fpga_ops_write() error: 'eemi_ops' dereferencing possible ERR_PTR() drivers/fpga/zynqmp-fpga.c:84 zynqmp_fpga_ops_state() error: 'eemi_ops' dereferencing possible ERR_PTR() Note: This does not handle the EPROBE_DEFER value in a special manner. Fixes commit c09f7471127e ("fpga manager: Adding FPGA Manager support for Xilinx zynqmp") Reported-by: Dan Carpenter Signed-off-by: Moritz Fischer Acked-by: Alan Tull --- Changes from v1: - Address Alan's feedback regarding handling both occurences. --- drivers/fpga/zynqmp-fpga.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index f7cbaadf49ab..b8a88d21d038 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -47,7 +47,7 @@ static int zynqmp_fpga_ops_write(struct fpga_manager *mgr, char *kbuf; int ret; - if (!eemi_ops || !eemi_ops->fpga_load) + if (IS_ERR_OR_NULL(eemi_ops) || !eemi_ops->fpga_load) return -ENXIO; priv = mgr->priv; @@ -81,7 +81,7 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) const struct zynqmp_eemi_ops *eemi_ops = zynqmp_pm_get_eemi_ops(); u32 status; - if (!eemi_ops || !eemi_ops->fpga_get_status) + if (IS_ERR_OR_NULL(eemi_ops) || !eemi_ops->fpga_get_status) return FPGA_MGR_STATE_UNKNOWN; eemi_ops->fpga_get_status(&status);