Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp387835rwe; Thu, 1 Sep 2022 00:48:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR66w3dXP0qT60kNsdk0s7k604zpRlfGbpUICvNQyIRgVX7HNNDBxpsZZiNHuyBsGlQUad7j X-Received: by 2002:a17:90b:17c9:b0:1fe:300a:e61c with SMTP id me9-20020a17090b17c900b001fe300ae61cmr6813488pjb.53.1662018529441; Thu, 01 Sep 2022 00:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662018529; cv=none; d=google.com; s=arc-20160816; b=W+6xCHaFWgf2WGFhddiEt/o3vdp1miFkz1I8sWhJfZTNU19CQ4vADdsP6AgFCGnQ+/ Tc7ZZhfoEiN5DGrqqlgTC4Ha/jzIGLGwd/h4C2mQZJTvjAokzEUjtA1QJA6uo4BI9RM+ DxS80kzcKFjfCD4jF0PC31iksCvPZVFSwd9XUMV/uwxAB5jsfmd2it7LxJK7B+VtxAUe 4v2B3CpwMPqWKa7YTxK9LhNoZrg8YzLdxtjHQ9cwhT2sXRgEaKaGxDBuULVpZX2s7Hz9 5dM4IXmEceZ1duqx3F3sYNp1rzC4SlsVTM6bCDz7VHtvaSsZiYvBf3DvzI4As/Pe+Goe LHjQ== 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=PdWFo7s1BvlZOANfCy1op23Qm/bp42PeFFGKCXr/AHI=; b=l0Vm50HQuE4YfdfTeAf3qrGt7Q4Y61Ylz6DbAt2PYO1+0k8x6TUYOJizhjBXSveu+k Ff//UAD1stlKYEZzR3pEwaeLK/zVdmELqmWtIpjnJ5eHC508tBdmtA7lIwgVcvF7jA+4 297pIm7h1o3a0ubZXFfYYkwuNtWbMZ3rI01l/oonqhU99t06SgvMjMemsIz4janQN92e wvMSSEUAXLz+l1DXWuCBePPvI5HmGI5USyZ/TskcsjAW5gEjNqCZvMpFvqKs6l4g7YYf pxeBDEIfBeLRcOuKIFrruApB/cJV7CSLBQ++CRDDxulEW5mJ1g8WI0fxf/aU+eKNeZ9s 9Igg== 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 q35-20020a63f963000000b0041c35254232si7311015pgk.869.2022.09.01.00.48.38; Thu, 01 Sep 2022 00:48:49 -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 S233780AbiIAHr5 (ORCPT + 99 others); Thu, 1 Sep 2022 03:47:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233399AbiIAHrQ (ORCPT ); Thu, 1 Sep 2022 03:47:16 -0400 Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6BA213F81 for ; Thu, 1 Sep 2022 00:45:29 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-03 (Coremail) with SMTP id rQCowABnyHETYxBjIoMgAA--.64009S2; Thu, 01 Sep 2022 15:45:24 +0800 (CST) From: Jiasheng Jiang To: hdegoede@redhat.com, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] virt: vbox: Add check for device_create_file Date: Thu, 1 Sep 2022 15:45:21 +0800 Message-Id: <20220901074521.3448337-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CM-TRANSID: rQCowABnyHETYxBjIoMgAA--.64009S2 X-Coremail-Antispam: 1UD129KBjvJXoW7CFWxGw1ruF1DuF1fGw1kuFg_yoW8Jw18pF 47Ca4ay3yFgw4jgw47ta4qqFyYgrWxt397urWxAw1rWr97A39YvFWDGayUZrZ8ZFZ5GF1r Xw1Utr1rCa1UWFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUyC14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4j 6F4UM28EF7xvwVC2z280aVAFwI0_Cr1j6rxdM28EF7xvwVC2z280aVCY1x0267AKxVW0oV Cq3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCF04k20xvY0x0EwIxG rwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4 vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcVC0I7IY x2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26c xKx2IYs7xG6rWUJVWrZr1UMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7Cj xVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUywZ7UUUUU= X-Originating-IP: [124.16.138.126] X-CM-SenderInfo: pmld2xxhqjqxpvfd2hldfou0/ X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 device_create_file() can return error number, it should be better to check the return value and deal with the exception. Fixes: 0ba002bc4393 ("virt: Add vboxguest driver for Virtual Box Guest integration") Signed-off-by: Jiasheng Jiang --- drivers/virt/vboxguest/vboxguest_linux.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/virt/vboxguest/vboxguest_linux.c b/drivers/virt/vboxguest/vboxguest_linux.c index 4ccfd30c2a30..0fee8e6ee6e0 100644 --- a/drivers/virt/vboxguest/vboxguest_linux.c +++ b/drivers/virt/vboxguest/vboxguest_linux.c @@ -390,8 +390,13 @@ static int vbg_pci_probe(struct pci_dev *pci, const struct pci_device_id *id) } pci_set_drvdata(pci, gdev); - device_create_file(dev, &dev_attr_host_version); - device_create_file(dev, &dev_attr_host_features); + + ret = device_create_file(dev, &dev_attr_host_version); + if (ret) + goto err_unregister_misc_device_user; + ret = device_create_file(dev, &dev_attr_host_features); + if (ret) + goto err_unregister_misc_device_user; vbg_info("vboxguest: misc device minor %d, IRQ %d, I/O port %x, MMIO at %pap (size %pap)\n", gdev->misc_device.minor, pci->irq, gdev->io_port, -- 2.25.1