Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4410580imw; Thu, 7 Jul 2022 19:02:12 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sI63pZCKfSrQ33hgIjgqK6av+MNqlIJOrZsEAl4n/Xej3pUSUPtAfPfYLNMRrkf3/ScZfx X-Received: by 2002:a17:902:d718:b0:168:d9df:4f1c with SMTP id w24-20020a170902d71800b00168d9df4f1cmr986636ply.41.1657245732345; Thu, 07 Jul 2022 19:02:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657245732; cv=none; d=google.com; s=arc-20160816; b=Vx0buxX5xtA8An9T1so6ASBRxzSZmnW4vNHQimK6zgg3iuzaDbWVifJYFaDauMJIGr rvHug40Ac5vhAsnPXi2hqkxP9CRn4FC4aZCcUdr8PFVUXVIn6H738xiKTdKKJm9TLwSW /YqHFOsCB2jQttRBg+IxTb9fIlQcKLhFKIiddON7Izb44Nz0D0nmd9Rh0zD2lXjV6PCO mF95h4kgFcMGKepwDxqIvhue6Pb4/BdQetTBAQaKagmz8CJk/LRNCpwsW5P1tS0OSXCy bno75t7+QYRPqmAjOQ1F+3ERR4jkJ088Wp1WUXS68RoZJFqTAQ0l8fLZnRXcRwtLHyAt 5+Ug== 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=YTxRLUvvUbdEWIjtReHBqowopMuwApVLVWJ3W49ZSKY=; b=AbnkkcKPyQPQ1T6gd/T1iOqgY2rOrYSH3BUk1l+CW+kHG806kLtbWTe2dgZYCUIemU I6q6qP0v3j1eaUxFAiU+pgO2uyo7Zg5Ip+/hWxSNLJF+U+FbWf4uXpSi2QR8HkMbs96S lbblpf4eaeLz5XUznVV337qWJkD77OGLzkIUxgkHvMmrtnTMyQ8wtAama/4tuXOqYHPq hLmUZ61xotDJolRqiGVvxWceyvXpOdhku3Wqm10U9RYqbJ+y7dlF/kOEuwCOy4DOqhfh FkGXfp5QTVHmyWeSqeV8zwrQJl/G6d90e/Ct9pZsPWLTBn0wu5sd+7pl0YAfkWOcBfxW eFVg== 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 ij24-20020a170902ab5800b00161d4849aa6si2907037plb.390.2022.07.07.19.01.48; Thu, 07 Jul 2022 19:02:12 -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 S236525AbiGHCAB (ORCPT + 99 others); Thu, 7 Jul 2022 22:00:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236471AbiGHB77 (ORCPT ); Thu, 7 Jul 2022 21:59:59 -0400 Received: from unicom146.biz-email.net (unicom146.biz-email.net [210.51.26.146]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADEB073905; Thu, 7 Jul 2022 18:59:56 -0700 (PDT) Received: from ([60.208.111.195]) by unicom146.biz-email.net ((D)) with ASMTP (SSL) id CYP00149; Fri, 08 Jul 2022 09:59:49 +0800 Received: from localhost.localdomain (10.200.104.97) by jtjnmail201612.home.langchao.com (10.100.2.12) with Microsoft SMTP Server id 15.1.2507.9; Fri, 8 Jul 2022 09:59:50 +0800 From: Bo Liu To: , CC: , , , Bo Liu Subject: [PATCH] bus: mhi: ep: Check dev_set_name() return value Date: Thu, 7 Jul 2022 21:59:48 -0400 Message-ID: <20220708015948.4091-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: 2022708095950ed6942c3ae8fce442d2f8adff4aa7a25 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=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, 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 It's possible that dev_set_name() returns -ENOMEM, catch and handle this. Signed-off-by: Bo Liu --- drivers/bus/mhi/ep/main.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 40109a79017a..1dc8a3557a46 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -1242,9 +1242,13 @@ static int mhi_ep_create_device(struct mhi_ep_cntrl *mhi_cntrl, u32 ch_id) /* Channel name is same for both UL and DL */ mhi_dev->name = mhi_chan->name; - dev_set_name(&mhi_dev->dev, "%s_%s", + ret = dev_set_name(&mhi_dev->dev, "%s_%s", dev_name(&mhi_cntrl->mhi_dev->dev), mhi_dev->name); + if (ret) { + put_device(&mhi_dev->dev); + return ret; + } ret = device_add(&mhi_dev->dev); if (ret) @@ -1408,7 +1412,10 @@ int mhi_ep_register_controller(struct mhi_ep_cntrl *mhi_cntrl, goto err_free_irq; } - dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index); + ret = dev_set_name(&mhi_dev->dev, "mhi_ep%u", mhi_cntrl->index); + if (ret) + goto err_put_dev; + mhi_dev->name = dev_name(&mhi_dev->dev); mhi_cntrl->mhi_dev = mhi_dev; -- 2.27.0