Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1187543rwb; Thu, 18 Aug 2022 21:46:15 -0700 (PDT) X-Google-Smtp-Source: AA6agR58jp1agbuKA7/cgJKQj577Yrr+4G+aK0Xvy6TP5dBilYv1iJ0v7wrloOJTEncvyupbJ3WR X-Received: by 2002:a17:902:e5c6:b0:16e:f3b6:ddb5 with SMTP id u6-20020a170902e5c600b0016ef3b6ddb5mr5625065plf.122.1660884375011; Thu, 18 Aug 2022 21:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660884375; cv=none; d=google.com; s=arc-20160816; b=GQ0z9INAFPLZnFtgh2MDqNF5duT8EYcqjsoupV/dDQyJj0+vFvGMggFhH8TtNjgkds x6fmqZ4SZQSauYKhjwpPRd6etHJrHjIuR9Hq04e1fxx+8MH6frimDcH5lbjlKF5p3Jl1 5VOqUq8kVUZcntVB7eN3/qSlBnYhy8xOGzgE9XmGargd01UtJ5bEN4ZDRTS4D2h0P1K+ YeZS2DEkzVUIchfIabtQMwuJqZ9p4yCRzU742motsMTu7+nf74211OuXvlp/lvUZ07RH lZcd6+0H5+EgHnOtHFU/Xjr+K1JtMevylZC8DZcRcFiKGrKlqwvyEq5r0HPEfhmSxOim VGcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=JNoh4kDQ39A8D+OsMgv+ZK9I4EgJAJY6ir+QLwoY0iE=; b=zKmqSpA9EwVLOY2SbRUEkuZb/n1BeIMaBpHdjg7+A1cfJBCUw7wQvjT0G8wUmSneA0 6FHq75OcIYMQRWPdaA46kLXLmZKqmb6pllC2wKRnt0Rb3Wz2Xa9WrZ/NgcFA6QRgMcfT 0GsIp/lSWbhSQSxXKoyZ3dDaVWozk04O1S3kA0mw2S+KFBZgBbaQgFI56RU8XnVIZ9OS Oif+ZfHYxmuPM69zvta7icAmkcQRY/CQExPnmCHrP9Wsbz2nYgiltJ+8rgWOvRpH1DMC vPzacB3GH56yqLxqLTmxQ+/U24ilGqtS6G1hrFk4YSgtgFJnFODCOlxbuedt4F9zn4Tg 0SxA== 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 mi2-20020a17090b4b4200b001ecdb25106asi3342031pjb.10.2022.08.18.21.46.03; Thu, 18 Aug 2022 21:46:14 -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 S1344942AbiHSEQF (ORCPT + 99 others); Fri, 19 Aug 2022 00:16:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbiHSEQA (ORCPT ); Fri, 19 Aug 2022 00:16:00 -0400 Received: from mail.nfschina.com (unknown [IPv6:2400:dd01:100f:2:72e2:84ff:fe10:5f45]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6A9C9DA3C4; Thu, 18 Aug 2022 21:15:59 -0700 (PDT) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id 54BE51E80D08; Fri, 19 Aug 2022 12:12:47 +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 y6zDthdFrvj6; Fri, 19 Aug 2022 12:12:44 +0800 (CST) Received: from localhost.localdomain (unknown [180.167.10.98]) (Authenticated sender: liqiong@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id 30EE81E80CFF; Fri, 19 Aug 2022 12:12:44 +0800 (CST) From: Li Qiong To: "James E . J . Bottomley" , Helge Deller Cc: linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, yuzhe , Li Qiong Subject: [PATCH] parisc: handle failure of kmalloc in ccio_init_resources Date: Fri, 19 Aug 2022 12:15:10 +0800 Message-Id: <20220819041510.75473-1-liqiong@nfschina.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 kmalloc(), it should be better to fix this error path, check and return '-ENOMEM' error code. Signed-off-by: Li Qiong --- drivers/parisc/ccio-dma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/parisc/ccio-dma.c b/drivers/parisc/ccio-dma.c index 9be007c9420f..f69ab90b5e22 100644 --- a/drivers/parisc/ccio-dma.c +++ b/drivers/parisc/ccio-dma.c @@ -1380,15 +1380,17 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr) } } -static void __init ccio_init_resources(struct ioc *ioc) +static int __init ccio_init_resources(struct ioc *ioc) { struct resource *res = ioc->mmio_region; char *name = kmalloc(14, GFP_KERNEL); - + if (unlikely(!name)) + return -ENOMEM; snprintf(name, 14, "GSC Bus [%d/]", ioc->hw_path); ccio_init_resource(res, name, &ioc->ioc_regs->io_io_low); ccio_init_resource(res + 1, name, &ioc->ioc_regs->io_io_low_hv); + return 0; } static int new_ioc_area(struct resource *res, unsigned long size, @@ -1543,7 +1545,10 @@ static int __init ccio_probe(struct parisc_device *dev) return -ENOMEM; } ccio_ioc_init(ioc); - ccio_init_resources(ioc); + if (ccio_init_resources(ioc)) { + kfree(ioc); + return -ENOMEM; + } hppa_dma_ops = &ccio_ops; hba = kzalloc(sizeof(*hba), GFP_KERNEL); -- 2.25.1