Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1121344iol; Sun, 12 Jun 2022 06:44:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyPZtLfo5zpD598qICR35iwoh3+Tmed9aomw4gBHXKheRR4uP/TU3HFbrCVsui3pAaSQohJ X-Received: by 2002:a63:1864:0:b0:3fe:4da9:d6a7 with SMTP id 36-20020a631864000000b003fe4da9d6a7mr17184807pgy.485.1655041492258; Sun, 12 Jun 2022 06:44:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655041492; cv=none; d=google.com; s=arc-20160816; b=Bl2GJFJXbapU8s6YNTjEDPKZeg01/qPDk5d3l7Y5XEzr3RkiK3Sit8bMKET6y1slce u8nJdJKFF3LCPquf1lRfC13oG5vMgRk3qXgDEoZIg3MqbiVoJidomWHbdjQOkjx9Kmph EQJA7sik9z8ePVzojHy7mAHq/Tf+nD40dmsyxo8cd22ZVMtL7NkTB82xgkd1h+9zeYNI ZWrsDZ5A4u/NNg69aHgoDgsp+GDmdHfqItIFCrMoVp8e7FBBeUh4L1qe1J7Z8nCHLvTS PkJIUebBPH1pG4afYWbxXpOjmm46MJG6j4SeHqv/pxjZ49GZWFsl2BkOSoWTeN4IuHNE ciAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=Vgt0APSNzJJJZCpnu/o75MJkGCq4hnxOmSc50suYp14=; b=whuVIvw4uhrLFAYCDBRIWUB65iovzHQYzvrLV6DKdNnX1tXcDCXgrMRBF2srhTn2sO mvHkoEBb3sqih9XUJifhDSmdVZ6ld7nMkwTnkXTsGxAqxLX3DCu/1Vsa/oX64nbYekYc XVa7lX3ZClx6vDX5mfRH9DHLySzeriihOGA2GRx8ltax7sAQw81sNI0xMYfxfqZ70nLK 9E59im9UceVQonhk2OoZOB0KpVHYgdSJsveq/oQYr850jnKtT+9TwHQgvoNBxtfIfPz3 ndElVJ/3CgrmlslqzhUvZUJdasJ+emNjBYyWOKeDuf1F8J319TDMsmsvo9bS/+sw/LN+ Nmwg== 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 a6-20020a1709027e4600b0015f13887fe4si6285716pln.200.2022.06.12.06.44.38; Sun, 12 Jun 2022 06:44:52 -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 S236863AbiFLM6C (ORCPT + 99 others); Sun, 12 Jun 2022 08:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231208AbiFLM5y (ORCPT ); Sun, 12 Jun 2022 08:57:54 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3C4BF64DE; Sun, 12 Jun 2022 05:57:53 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 338C81E80D89; Sun, 12 Jun 2022 20:56:49 +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 HGN2UNlKuFNX; Sun, 12 Jun 2022 20:56:46 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 15CA41E80C8B; Sun, 12 Jun 2022 20:56:46 +0800 (CST) From: Li Qiong To: Sergey Shtylyov , Damien Le Moal Cc: linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, yuzhe@nfschina.com, renyu@nfschina.com, Li Qiong Subject: [PATCH v2] ata: pata_pxa: handle failure of devm_ioremap() Date: Sun, 12 Jun 2022 20:57:00 +0800 Message-Id: <20220612125700.11740-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20220612073222.18974-1-liqiong@nfschina.com> References: <20220612073222.18974-1-liqiong@nfschina.com> 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 Reviewed-by: Sergey Shtylyov --- v2: - add driver's name (pata_pxa) to subject. --- 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