Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp468312rwe; Thu, 1 Sep 2022 02:38:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QAAZMpdzTVKHp6G7wsGtBQWxcrWePlT8yRtVsgZ0aJmp6vMKkzAMba09yyigsm+f1f1Sn X-Received: by 2002:a17:903:2102:b0:174:4d5f:8abf with SMTP id o2-20020a170903210200b001744d5f8abfmr27156375ple.11.1662025096359; Thu, 01 Sep 2022 02:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662025096; cv=none; d=google.com; s=arc-20160816; b=rDLXFfm1pSgeZ4ntKtyHQCrGfb+/l0zri8QEP/dI2PU65mW6I5TKJdL+/bqe6iygNy JyT6va0ONFyb4RuzpHEJ4ojCIpLzh64UegDedp9HD5XRsogaGmIfgtpAFgNZMxCxDrRQ qakTWA8GBvPjE3SUubWLsfNNqJrWkOGFZr/eBV5al5o3ry/b2jM5dWntOgTJjcy5mAvY AREFjGR/D75I4HbO4JO3tpWMGsWemzNCX0LHMZ3dJ+ZqHRhHnSDZ1d453v0EspHNEhEE +B6Gvy6mdyI2MTYk9s8tJxzpiJ9dFlucWfhsrV3qurbGRuWrxnR0YZELklBoflD+itlN /1Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=l3Zn48QFI5l8eP0yleg92po/+EF4Zrd3LBIi3kLHajE=; b=QPGiuVH11XozKZEBSbWG6R6Gc37rKKDTTfW8zl6y8PZCgXfJ9Y7/zsJiXSMhortj0K +LvPjqSPa9I7cUgRSh2CoDI7BefDBEtYexSv1NtBAWS8vBLk1t6L8DtfW7pvX/UxmV7f skdeGzkPiVC8AVBn9afZLVGcmD69rv+ft1xg7odWNufTfWVPcbCmhpjcgWMO1lHhSHw7 40TTg+1pHRzhKM+dYB4BGMBG695j0fmLGwflkS9/L47yC8YupcbORA1ZUXvB4EtLy4sX wNhpeVk/H8tQfvUISc1KaX8Caeh7k5KZ8QjqlEGTsMX2Ezg+NqwuzW7pXmyeA/ptn1Tt 801g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pb1dVILh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ip2-20020a17090b314200b001fd73f8193csi3970590pjb.10.2022.09.01.02.38.05; Thu, 01 Sep 2022 02:38:16 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Pb1dVILh; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234097AbiIAISY (ORCPT + 99 others); Thu, 1 Sep 2022 04:18:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233487AbiIAISR (ORCPT ); Thu, 1 Sep 2022 04:18:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1877A12D504 for ; Thu, 1 Sep 2022 01:18:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id DE88261E00 for ; Thu, 1 Sep 2022 08:18:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CDE58C433C1; Thu, 1 Sep 2022 08:18:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662020293; bh=SJti5AlwG2smz35iBVA8XDbLCLC67wZdHYc+9fqVbXY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pb1dVILhPHNKqfWSEAI/tUlkXYHUEI01IWEePIoQYrIaw8EaAYhNyDGBklePtxOjI LrYCeNCYK9v0OpGfbxqPXJ4ZpqIIJ1w4j3z3wzO1BTGMFm3lZFVbFHhNBOBg0jLTC3 S//qOMMjmd1I9RS5nIpN1W+MoV8mAump2Kqw5RpA= Date: Thu, 1 Sep 2022 10:18:10 +0200 From: Greg KH To: Jiasheng Jiang Cc: hdegoede@redhat.com, arnd@arndb.de, linux-kernel@vger.kernel.org Subject: Re: [PATCH] virt: vbox: Add check for device_create_file Message-ID: References: <20220901074521.3448337-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220901074521.3448337-1-jiasheng@iscas.ac.cn> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,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 On Thu, Sep 01, 2022 at 03:45:21PM +0800, Jiasheng Jiang wrote: > 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; This is also buggy, please always test your changes before sending them out :(