Received: by 2002:a05:6358:e9c4:b0:b2:91dc:71ab with SMTP id hc4csp1344276rwb; Thu, 4 Aug 2022 23:30:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR7xugsJW4oFNfVSvW36Uk1W0USwtnCSL+34NGTAOT44wPM7h9YsWhqs8TdbhU1vXyO3A4W6 X-Received: by 2002:a63:8b43:0:b0:41c:cb91:2c47 with SMTP id j64-20020a638b43000000b0041ccb912c47mr4530823pge.609.1659681035335; Thu, 04 Aug 2022 23:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659681035; cv=none; d=google.com; s=arc-20160816; b=H/SFuycHMmTcT4P9Pdd57xm7Qu7DfHwQjv5kE/03DkAolEzgsIdhIm+gbq+jHQozpC cInD3l1m95SPJuKupBSYIeyjYQnXy6DVdKlA9So/S/RnFGJ/oz34SFw23a2yIw3JZ3dT ct/D0a7jBvZUTHw9N7tysc9KW6t+zBncf4ohpitvhrC5348gy9+MtjQHRH+RE4hOPR6p lDWrbohq1n9JS/R24yhS3hUsPQX6GqHJzXE7XwYwA7Q6eXsU4kTXCnRVUf/SLDXwU5i2 VfOWsalc1E5fgVoPNTxR8gfIImXQffv/83vmZoCBkBZBCs8sE0nvY6tdB/nmV/bDhfNY Ie9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:abuse-reports-to:tuid:mime-version:message-id :date:subject:cc:to:from; bh=ofyVp4YiY34DWMn4t/VwwWZQAESWZICA31K6eoikqdA=; b=qzSvR267073qGDDV+ejAnqr9gk7vASrhmibaE8wVEtVfVOaG7UNw+sOpmvWV74qBa5 m54/dSOGz5izj/QTRz2D1smXFcpj9VEnF+8EIcug/Q+t3SdX2iMms9suVibHFn1eqJ7a Lz/rasQ1GT0El0DNGJQmnte6NS/cS4B0QGzXuo01pfkiCgB3E8nax+tqGhoZovKMO/hG kaiKKX/CTE1ksyd4d0ShyGaSqgGM3EM4Ai3alBoEr3v62iLhPzXhbeI7SVL/RrXX+zWu C0VlZyMSt38ULQcjzbuiCm33qWiJY9xpTLgRVKfmTvFVDGcxyIasU3r3A6Cg802+TcBD hCsg== 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 l184-20020a6388c1000000b0041ca87ef075si2039156pgd.201.2022.08.04.23.30.20; Thu, 04 Aug 2022 23:30:35 -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 S235377AbiHEFda (ORCPT + 99 others); Fri, 5 Aug 2022 01:33:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232456AbiHEFd3 (ORCPT ); Fri, 5 Aug 2022 01:33:29 -0400 Received: from ssh248.corpemail.net (ssh248.corpemail.net [210.51.61.248]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E036E2EF for ; Thu, 4 Aug 2022 22:33:26 -0700 (PDT) Received: from ([60.208.111.195]) by ssh248.corpemail.net ((D)) with ASMTP (SSL) id ZDM00019; Fri, 05 Aug 2022 13:33:19 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201605.home.langchao.com (10.100.2.5) with Microsoft SMTP Server id 15.1.2507.9; Fri, 5 Aug 2022 13:33:20 +0800 From: Bo Liu To: , , CC: , , Bo Liu Subject: [PATCH] dax: Check dev_set_name() return value Date: Fri, 5 Aug 2022 01:33:19 -0400 Message-ID: <20220805053319.3865-1-liubo03@inspur.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.200.104.97] tUid: 2022805133319b82b3ecbb11bc9c5f2588e7020cc85a0 X-Abuse-Reports-To: service@corp-email.com Abuse-Reports-To: service@corp-email.com X-Complaints-To: service@corp-email.com X-Report-Abuse-To: service@corp-email.com X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS 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 It's possible that dev_set_name() returns -ENOMEM, catch and handle this. Signed-off-by: Bo Liu --- drivers/dax/bus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/dax/bus.c b/drivers/dax/bus.c index 1dad813ee4a6..36cf245ee467 100644 --- a/drivers/dax/bus.c +++ b/drivers/dax/bus.c @@ -765,7 +765,12 @@ static int devm_register_dax_mapping(struct dev_dax *dev_dax, int range_id) device_initialize(dev); dev->parent = &dev_dax->dev; dev->type = &dax_mapping_type; - dev_set_name(dev, "mapping%d", mapping->id); + rc = dev_set_name(dev, "mapping%d", mapping->id); + if (rc) { + kfree(mapping); + return rc; + } + rc = device_add(dev); if (rc) { put_device(dev); @@ -1334,7 +1339,9 @@ struct dev_dax *devm_create_dev_dax(struct dev_dax_data *data) dev_dax->region = dax_region; dev = &dev_dax->dev; device_initialize(dev); - dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); + rc = dev_set_name(dev, "dax%d.%d", dax_region->id, dev_dax->id); + if (rc) + goto err_range; rc = alloc_dev_dax_range(dev_dax, dax_region->res.start, data->size); if (rc) -- 2.27.0