Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp4810714imm; Mon, 11 Jun 2018 20:10:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKP0KX/tLrdijJJoL+mSyR7UNpQUStUUIHqlxvOsGMUJwJXCgl40FNthtdtbvEdixzMuLBM X-Received: by 2002:a17:902:ac89:: with SMTP id h9-v6mr1939844plr.311.1528773015805; Mon, 11 Jun 2018 20:10:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528773015; cv=none; d=google.com; s=arc-20160816; b=Qj1p4WW9kYZFKMK9+5yTcsWmETTREgeqmzWXkXfdkvGAibcmxQvU+VFkCVa/nq0Lg2 IPCpRXCFxjFovHReplz+q25dG+UwZ0rgG8V1WVDF9tr1BuSnjLob/MYdYOLg/7opJdcC ynD0rrdQrJTmEufn3i7vrVaN9yIHN0hEb/bRKGJswgU7q1fDIpakK8tpPCYpggOAZCvO W9BQ4Voxx9nKgKv9XPJ5N640PzHfpAmlE8l+l3oOrAS77PDXu109SfiCISuNEsJyHmBC 2WMSsdDnkMOKfqGAWovnVSdW3DbRihbyZjIc1Sji0TViQhjFRNTcvDSDMnV5m2Qqv+VW UM7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature:arc-authentication-results; bh=FeSs9z2tOvd9LpmD0hBtuH9rGnCqqNaLK9dCQT5zjvA=; b=ID4c7wyJOxJmfUd9C9zu8RWyRCMOnuZdRly2sTMzJzx3Q3bjx/6R/leBFXdCehgUOB fKUhL3n+yHn/Y8kvDZy/kBAGd0laLiezwLHHxMUtYlb1WFas22sEvgdEXtu0uLtwovm+ FVx/bSXc8P7cMIJC3mV0INDeEc4xAsPRcJxgduugFb7MQPHI8mJ6crVZI7Rb1oTiDn6T 4DL5n9kE410rFVaobDMZUgeqgk5cbD68XW0Nkh06qFISUg2OBqiwNMMwSefhixTfUilu jCbbKQG7EIBXH/uj6Dt7QkZiN0RPNhC2eHYCXZ/wL3z5qgT15r4Ei5w4ix6X0YG/GSYN u/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Sp0t8AAa; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f8-v6si45382508plt.35.2018.06.11.20.10.01; Mon, 11 Jun 2018 20:10:15 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=Sp0t8AAa; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964822AbeFLDJk (ORCPT + 99 others); Mon, 11 Jun 2018 23:09:40 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:32877 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935193AbeFLDJj (ORCPT ); Mon, 11 Jun 2018 23:09:39 -0400 Received: by mail-pl0-f66.google.com with SMTP id n10-v6so13494607plp.0 for ; Mon, 11 Jun 2018 20:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=FeSs9z2tOvd9LpmD0hBtuH9rGnCqqNaLK9dCQT5zjvA=; b=Sp0t8AAaCMZMHhQsyGRCzlW8D78KBvNpDEOtzHzQFzUX5h962EXga6N+l2K9kNmfnO r2AcS3ho/s3XbDSk/2NhbB3b6WM3o2E6ugiT5o/IzR4FrIwk6RszpYfF+QEkEoULSX9V uDpWKUiCHjbKsfHb3UDWe1jFnWvZ4MZ/chXMxVmK89Sz6gIU4Nl7NDVz32nJx0dy085t FzDYm/EOixlR/tYWSwjMAK2kh5JYwflcYII2T3Xemh5qgd5tJau7VEoYoD1YsWscDEY2 iykUEsJdcIwLm7Rv+wT8HKEqzQuVvL7MlLIUpVwUEB0EChMxwrOA4GNaTDYjkiRO9u3n VHNw== 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; bh=FeSs9z2tOvd9LpmD0hBtuH9rGnCqqNaLK9dCQT5zjvA=; b=mg4aWZyW1YTkG9jm53NVB3hN0DLJ2iBctNGtI3il26GjTBBKiluYgrkoIVVI/8KbDC MQm427nBLsyJoBdG2E8uxF8e6ZDn9e+3F2uHUaXV86rMfhwMbRxmVjnKZ736HtMQswlI vMp94d9xhkQlaU7tV43wCkNhpvZTCEodhvpY/5mDegud2GJiqFDkcHFZtm/RNVxF9wVs uI48V9cyakcFyAXOGmbZZrCYWdbMnMI4QPZJWgyTTuTJTctAgcFx9wzarkZXRVYlHo13 WQyoNxvahnaAAF2xUqWH2vDckYWNlMjTPtqtODJ7vStQ7mXsc6JAeLQTdt+yTIl/En/B asTQ== X-Gm-Message-State: APt69E3m4Pjolx7UsWpzuJ82iR6ilUJIGlSLXI+fGsIs8vYcEj5tgc+L 8sW3+Wsz6j1+Kx1JDLjU54I= X-Received: by 2002:a17:902:6acc:: with SMTP id i12-v6mr1968754plt.278.1528772979253; Mon, 11 Jun 2018 20:09:39 -0700 (PDT) Received: from localhost ([103.88.46.82]) by smtp.gmail.com with ESMTPSA id l14-v6sm40985662pfi.6.2018.06.11.20.09.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 20:09:38 -0700 (PDT) From: Zhouyang Jia Cc: Zhouyang Jia , Samuel Iglesias Gonsalvez , Jens Taprogge , Greg Kroah-Hartman , industrypack-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] ipack: add error handling for ioremap_nocache Date: Tue, 12 Jun 2018 11:07:21 +0800 Message-Id: <1528772844-36988-1-git-send-email-jiazhouyang09@gmail.com> X-Mailer: git-send-email 2.7.4 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When ioremap_nocache fails, the lack of error-handling code may cause unexpected results. This patch adds error-handling code after calling ioremap_nocache. Signed-off-by: Zhouyang Jia --- drivers/ipack/carriers/tpci200.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index 9b23843..1612f51 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c @@ -304,6 +304,13 @@ static int tpci200_register(struct tpci200_board *tpci200) ioremap_nocache(pci_resource_start(tpci200->info->pdev, TPCI200_IP_INTERFACE_BAR), TPCI200_IFACE_SIZE); + if (!tpci200->info->interface_regs) { + dev_err(&tpci200->info->pdev->dev, + "(bn 0x%X, sn 0x%X) failed to map driver user space!", + tpci200->info->pdev->bus->number, + tpci200->info->pdev->devfn); + goto out_release_mem8_space; + } /* Initialize lock that protects interface_regs */ spin_lock_init(&tpci200->regs_lock); -- 2.7.4