Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1219568iol; Sun, 12 Jun 2022 09:20:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaOqjQG5Zk7yoIntgP2LdoeqNb4KdMPvg+9gr1+f/PufMosWoSQJLuTX3GR3XfBERcXkzn X-Received: by 2002:a17:902:e889:b0:167:523c:6011 with SMTP id w9-20020a170902e88900b00167523c6011mr45313313plg.114.1655050813839; Sun, 12 Jun 2022 09:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655050813; cv=none; d=google.com; s=arc-20160816; b=ojSbxyBjc/2JQvr7LwJDpWaiofmp41i9+2Q5w5i99sbdvsSOvHlKx2uRmVGcPdkez7 H7+ymnMXQOAwp5lBLZqoqp3cexKRwsMybOZHjzmtJh7JT8uIAKKMWkaom9CIX87+oux7 fHSKFoQtjmOsiYzzgBx8M275XyhxWrfGrPYQFnNE9uT/Mx8uijvCmJ1jj5CxMR1YBzro UoYhmc8s0UGEMuDyZGJdBYqEQII8TVyxpj6OPOd2NcXn4Tvky9GUy/Tb5/y0ZIp3OWcp Wsud4uHXgeYBoBZG3sX2xaWeH5Egukxw5XtUmwDPZsm8q6SB4NzDj82gByeBDtTxkJ2n aO4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=NuxUbTxGnHSpITO/QZVOlzMs94N94AhvHStcSZ5GUWc=; b=fucV/zU0cU8Y1iiBWtwHGihPupBs+ucWVTqDtNxvOhIwu4Uc9RWOejLH02vKzxwtX0 I/9B0NeTRkcGx+yQRTS8cXWAtGqL2kxHDXadZ4vFrTGtbU7E8AXCLw6vWpWhFt/4zbxk erP0SGUMqV+ZDMbmi7qIFJMnQXTnH5TESnHEpiEEgxnky+Q6w15X6BBbPzhgQ+9/YjvL wuCY7zlqMl2e3mnrWEnksVCDth4HUzldNex+lXbzfHRTHkatlmQAOtMq5uupUqN/vPCM OPToH5pqOqTQ3XnCuwBceAR+55rQLuz+GLKJ4zgLKHHjEI074vhJFDwv8TdayybG2dX1 7WQQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k17-20020a170902c41100b00161d4849a90si8619369plk.575.2022.06.12.09.20.02; Sun, 12 Jun 2022 09:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234625AbiFLHdg (ORCPT + 99 others); Sun, 12 Jun 2022 03:33:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229559AbiFLHdf (ORCPT ); Sun, 12 Jun 2022 03:33:35 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4005539811; Sun, 12 Jun 2022 00:33:31 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id A63431E80D89; Sun, 12 Jun 2022 15:32:29 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id D6JU9v0rtj7Y; Sun, 12 Jun 2022 15:32:27 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 56DFD1E80C8B; Sun, 12 Jun 2022 15:32:26 +0800 (CST) From: Li Qiong To: Sergey Shtylyov , Damien Le Moal Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, hukun@nfschina.com, qixu@nfschina.com, yuzhe@nfschina.com, renyu@nfschina.com, Li Qiong Subject: [PATCH] ata: handle failure of devm_ioremap() Date: Sun, 12 Jun 2022 15:32:22 +0800 Message-Id: <20220612073222.18974-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As the possible failure of the devm_ioremap(), the return value could be NULL. Therefore it should be better to check it and print error message, return '-ENOMEM' error code. Signed-off-by: Li Qiong --- drivers/ata/pata_pxa.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/ata/pata_pxa.c b/drivers/ata/pata_pxa.c index 985f42c4fd70..cd1a8f37f920 100644 --- a/drivers/ata/pata_pxa.c +++ b/drivers/ata/pata_pxa.c @@ -228,6 +228,11 @@ static int pxa_ata_probe(struct platform_device *pdev) ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start, resource_size(dma_res)); + if (!ap->ioaddr.cmd_addr || !ap->ioaddr.ctl_addr || !ap->ioaddr.bmdma_addr) { + dev_err(&pdev->dev, "failed to map ap->ioaddr\n"); + return -ENOMEM; + } + /* * Adjust register offsets */ -- 2.11.0