From patchwork Fri Sep 18 12:56:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Qilong X-Patchwork-Id: 1366900 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-ide-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4BtDFM04GKz9sR4 for ; Fri, 18 Sep 2020 22:49:59 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726121AbgIRMt5 (ORCPT ); Fri, 18 Sep 2020 08:49:57 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:55596 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726064AbgIRMt5 (ORCPT ); Fri, 18 Sep 2020 08:49:57 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1535C833ACD271E2DAB4; Fri, 18 Sep 2020 20:49:55 +0800 (CST) Received: from huawei.com (10.90.53.225) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.487.0; Fri, 18 Sep 2020 20:49:51 +0800 From: Qilong Zhang To: CC: Subject: [PATCH -next] ide: add the return pointer check for plat_ide_probe Date: Fri, 18 Sep 2020 20:56:45 +0800 Message-ID: <20200918125645.17309-1-zhangqilong3@huawei.com> X-Mailer: git-send-email 2.26.0.106.g9fadedd MIME-Version: 1.0 X-Originating-IP: [10.90.53.225] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-ide@vger.kernel.org From: Zhang Qilong If io map failed in devm_ioremap/devm_ioport_map, base or alt_base will be null, it will cause setup port error later but it won't be found out in plat_ide_setup_ports. Signed-off-by: Zhang Qilong --- drivers/ide/ide_platform.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/ide/ide_platform.c b/drivers/ide/ide_platform.c index 91639fd6c276..fdbc565ef142 100644 --- a/drivers/ide/ide_platform.c +++ b/drivers/ide/ide_platform.c @@ -86,6 +86,11 @@ static int plat_ide_probe(struct platform_device *pdev) res_alt->start, resource_size(res_alt)); } + if (!base || !alt_base) { + ret = -ENOMEM; + goto out; + } + memset(&hw, 0, sizeof(hw)); plat_ide_setup_ports(&hw, base, alt_base, pdata, res_irq->start); hw.dev = &pdev->dev;