Received: by 2002:a05:7412:8d11:b0:fa:4934:9f with SMTP id bj17csp365134rdb; Sun, 14 Jan 2024 22:35:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IFxLBXZe1aS5OTB/K/kGj70VN78skGtzBr4hJ5SnXwGxxGEDVC+96d2l2rKQpqFAEclAl9b X-Received: by 2002:a17:902:8e88:b0:1d5:6600:3d96 with SMTP id bg8-20020a1709028e8800b001d566003d96mr6050011plb.0.1705300504923; Sun, 14 Jan 2024 22:35:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705300504; cv=none; d=google.com; s=arc-20160816; b=ETjEfRhyj8wG7J688DP7WiDQ2P7R8tM1EdM6gbw+j60YP0mPQ2DXOGF0aRo/b6l5hJ OBctK9Nla5qA8vPl/ovLCu5VR2uTqqgKVEmyiwkyjWxMcc8y2TsU0jgHZsWBaEUWSxtk v4zRKx9NpO4okeafIbhlJgwjGzfCzLSHjhTo5m2iESh8CMT5rLyN269M1bdbJS7S6vVg F5mCqLn46doMWLj0CcCQK3ZjOUL6CNRApP0kHahUwQdJQ+D66p7bSolnlm5sO8F1Yjci /xNxhDdVe+LJ3sDZBVEUNZUysHVY0YXAKKO92uat/3BW2J76QU8EY0CPzvgIRR1gkKW5 x48A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=DVGqlrN41UhJXR1s4fXfXMuVgL7U7h7KH87TAC5Xr+Q=; fh=iubXruiasBqlL8CXS753YoZ4K4fVzYiGYiT5DHt4Vn8=; b=WqYmZ0gv+CJ3ZfSZCJWlmhROWMgFjjgLkN7RzdeWUgthaFvn2wyfceM/qCq7G3I2wB UpwWb3VszpBGd+M0FAPZYutNrN11PPXfx3xMytGNEQc2ZGQHqOIt9rvIY6Y46H0tzb6S ESRh3jW/GINEAcpwQ1HGy7F6sYkVJsM46hODh80rqv8+imgz/e+y7bjFPygLY2wSdhDO yKnrWhH3N57p3uBiOB7Dhdh7enAy9eAHpScNE7PyaJZfJs2cD+xa1XwDY+AuYj7907Wd J+L//xu7YlTyq0FoNtr/DIwnUqKgbzWdlK7qNcdy3bM7+ICxv8qR7p6odRMLacFjNhsO HPPw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25660-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jf22-20020a170903269600b001d4e20757dfsi8158061plb.177.2024.01.14.22.35.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jan 2024 22:35:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-25660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-25660-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-25660-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 99F5828148F for ; Mon, 15 Jan 2024 06:35:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B55CF5CA1; Mon, 15 Jan 2024 06:34:54 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E65D522B; Mon, 15 Jan 2024 06:34:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: 37fabb17f9ea4358ab45ae9f4848a456-20240115 X-CID-O-RULE: Release_Ham X-CID-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:5cdaf591-cd0d-448e-841a-60b734cb7632,IP:10, URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-10 X-CID-INFO: VERSION:1.1.35,REQID:5cdaf591-cd0d-448e-841a-60b734cb7632,IP:10,UR L:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-10 X-CID-META: VersionHash:5d391d7,CLOUDID:c7c35a7f-4f93-4875-95e7-8c66ea833d57,B ulkID:240115143441BZBJPDFA,BulkQuantity:0,Recheck:0,SF:44|66|24|17|19|102, TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0 ,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR X-UUID: 37fabb17f9ea4358ab45ae9f4848a456-20240115 X-User: chentao@kylinos.cn Received: from kernel.. [(116.128.244.171)] by mailgw (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 233800738; Mon, 15 Jan 2024 14:34:38 +0800 From: Kunwu Chan To: alex.williamson@redhat.com Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan Subject: [PATCH v2] vfio: Use WARN_ON for low-probability allocation failure issue in vfio_pci_bus_notifier Date: Mon, 15 Jan 2024 14:34:34 +0800 Message-Id: <20240115063434.20278-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. This is a blocking notifier callback, so errno isn't a proper return value. Use WARN_ON to small allocation failures. Signed-off-by: Kunwu Chan --- v2: Use WARN_ON instead of return errno --- drivers/vfio/pci/vfio_pci_core.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index 1cbc990d42e0..61aa19666050 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -2047,6 +2047,7 @@ static int vfio_pci_bus_notifier(struct notifier_block *nb, pci_name(pdev)); pdev->driver_override = kasprintf(GFP_KERNEL, "%s", vdev->vdev.ops->name); + WARN_ON(!pdev->driver_override); } else if (action == BUS_NOTIFY_BOUND_DRIVER && pdev->is_virtfn && physfn == vdev->pdev) { struct pci_driver *drv = pci_dev_driver(pdev); -- 2.39.2