From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiner Kallweit Subject: [PATCH 2/3] iommu: improve handling of failed call to kset_create_and_add Date: Tue, 28 Jun 2016 20:39:54 +0200 Message-ID: <00b60d38-f397-58b0-2a05-919649fc1e68@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org List-Id: iommu@lists.linux-foundation.org If kset_create_and_add fails then most likely due to out-of-memory. There's not necessarily a bug somewhere. Therefore I think we shouldn't use BUG_ON and simply return -ENOMEM. That's also what other callers of kset_create_and_add do. Signed-off-by: Heiner Kallweit --- drivers/iommu/iommu.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index debce45..b36ec9c 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1483,9 +1483,7 @@ static int __init iommu_init(void) { iommu_group_kset = kset_create_and_add("iommu_groups", NULL, kernel_kobj); - BUG_ON(!iommu_group_kset); - - return 0; + return iommu_group_kset ? 0 : -ENOMEM; } core_initcall(iommu_init); -- 2.9.0