Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1573228rdg; Sat, 14 Oct 2023 07:39:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGA2fIlzRlzcklcE1A6eFEsHQHyIoUj5xKzf/xT0IQBvR6tS7yEIpM5WxKT6IZoH1MzJKrN X-Received: by 2002:a05:6a00:2191:b0:68a:4261:ab7f with SMTP id h17-20020a056a00219100b0068a4261ab7fmr31395977pfi.31.1697294397241; Sat, 14 Oct 2023 07:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697294397; cv=none; d=google.com; s=arc-20160816; b=DtD2l1KO0cCtDXR9+mu+IyuuTXnkXmZmXfpGBCxmM/YqCP5v4LxmjHSa6Xw0u2LV64 jgP+GXHEGjzruXmR12ukm2Bo4Nb6qKHQhwPPGeoft8+c+UB6/qZYmgNSODvf+vxjpBv5 xKpuC4IL83BGzdA8DaGNfykj7pX9MLBpteQQhxR8kOUQT7KsBzJLwWh8t6c7a+wOvzrv B2PYeSterFXQ0ILNGiCqXx+aCCxCuyV8vwBPy6D5deXZh2WEZp8BXZbmRy+WpTrb62Yf yGCVEd3F4GkTS3QGsjUdGmYWFluMtSjuxHVr7IQnUVuNf23s4M36KegAXWjCyaQuZuB9 KX1A== 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; bh=vyMgoERQ4FN05dJMQjftnW6m1ZYvP1/dj3Xn0ojp3DU=; fh=KUWtKAY8aBMG6JdjPTs1qkVFM49c8GQJ0f5GJPrIYZI=; b=JJGoHd0+6e8rIfydT4u9rZ4u2molsdLNmsB9EAUWbePQ/vm846urqOq9JYoz5SLfLr OJrsC/t/AX5vn8FHDfgf8caqjVtx1j9/PZGe5euUOLwX0fqtGc2l3qcqwJq0pUlEin9a jVHN0lXqG8QtHOLOaP9BgaClcK9In0wIDtlPqnJGX/CnbHwOkbOAh/hsX5s7RZnuhusC Or/D3HerPlEgiTKokHyZTK3/aaAIKh27bwPhemISA0OEyU8KGhXv6gnD7KhLj3VpcJ+o xR/gALmuGpeHzvY6uscwoo5H0wiSg/wtlhyCSACRDl1HAQR+uioxub0AiFZMPO+CSKP1 uj4g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id d19-20020a056a0024d300b006b47a8c2a67si3375244pfv.359.2023.10.14.07.39.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Oct 2023 07:39:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=harvard.edu Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 16B56805114C; Sat, 14 Oct 2023 07:39:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbjJNOjo (ORCPT + 99 others); Sat, 14 Oct 2023 10:39:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233033AbjJNOjn (ORCPT ); Sat, 14 Oct 2023 10:39:43 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 1086BCC for ; Sat, 14 Oct 2023 07:39:40 -0700 (PDT) Received: (qmail 76119 invoked by uid 1000); 14 Oct 2023 10:39:39 -0400 Date: Sat, 14 Oct 2023 10:39:39 -0400 From: Alan Stern To: Zhang Shurong Cc: heikki.krogerus@linux.intel.com, gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usb: typec: retimer: Check dev_set_name() return value Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 14 Oct 2023 07:39:55 -0700 (PDT) On Sat, Oct 14, 2023 at 05:24:53PM +0800, Zhang Shurong wrote: > It's possible that dev_set_name() returns -ENOMEM. > We fix this by catching the error and handling it. > > Fixes: ddaf8d96f93b ("usb: typec: Add support for retimers") > Signed-off-by: Zhang Shurong > --- > drivers/usb/typec/retimer.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/usb/typec/retimer.c b/drivers/usb/typec/retimer.c > index 4a7d1b5c4d86..f163856a78cd 100644 > --- a/drivers/usb/typec/retimer.c > +++ b/drivers/usb/typec/retimer.c > @@ -122,8 +122,13 @@ typec_retimer_register(struct device *parent, const struct typec_retimer_desc *d > retimer->dev.class = &retimer_class; > retimer->dev.type = &typec_retimer_dev_type; > retimer->dev.driver_data = desc->drvdata; > - dev_set_name(&retimer->dev, "%s-retimer", > + ret = dev_set_name(&retimer->dev, "%s-retimer", > desc->name ? desc->name : dev_name(parent)); > + if (ret) { > + dev_err(parent, "failed to register retimer (%d)\n", ret); > + put_device(&retimer->dev); > + return ERR_PTR(ret); > + } > > ret = device_add(&retimer->dev); > if (ret) { It should not be necessary to do this. If dev_set_name() fails then device_add() will also fail. Alan Stern