Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1748826pxp; Mon, 7 Mar 2022 01:19:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJyfa6CXZoMDIN1afANROoWiV8DIF/Bb5qgtQwoWzu27tOrmsGGZirQEY8S7a2KRjpydUyJZ X-Received: by 2002:a05:6402:50c8:b0:416:2ae0:4bb3 with SMTP id h8-20020a05640250c800b004162ae04bb3mr8331112edb.132.1646644773457; Mon, 07 Mar 2022 01:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646644773; cv=none; d=google.com; s=arc-20160816; b=hn4Bpr4K5x8ULHXehw2kKd9s6prrhg/UjpQEan4QZHhp3dhZ5QekE7/lVbENYfu7sq u1klV7pb9T2HngfaifMAIzpLpcjgalfK2wpS2si3KvGjTRPfnAV/XoCoG5mXN1CHlofW AOCkXhpbVPo5XexD6bh21NOB79GWD0s3+G2AfPf9ENSI7R2ZxrXac3zWAvuc9VDq5J/O s2jXPpHFGIV7g0lGt+zoXJ1oUF9HM4t+NWeN7GGIGZ3n7BeO6nQJPus1Rlx0fdJ0N1og CR4iP9IDNC4C/4XOkVLf17kBLjnGFztnCWKX0/V/6ZY1AVLvZoGgn6KBavZGbzrmHvyD DqEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3GmDZYi4u1qi2UI5mnbc01oOxaZZdXpA01oXVaEo5vQ=; b=e2blxslz9Qwkp+v2iS15ON24w44bgpxRx/84y2awKU3tPGQ8p2z2gxj8Q+Pam8EwqO Z2nPw9ylrg8rT2RvSD4aThN66IO0Qtpd7mmrPKVy6QXS3H+W41wLq0REG/GVFxKqXkFq sefQNn7iOvlnDDYmWQFDC4GE45fumZUgnAORPc7vSZfEVId4RWTN7v9W9oiRsJTS2+m/ VZUbtruTdGysY7T/ezlagmago19x/gtSOH9aCSrog1Yjc76neWHKEuABRntZ4VI1QY+r 7YIn0lA7CRVuNrkXsqOZHJIqk2cs7i9HGHhHkSnO47a/S5NpIQZP47ki8yb1Al2iWgGN 4UdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gnQFlufo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ck2-20020a170906c44200b006d58fc597f9si8295686ejb.24.2022.03.07.01.19.10; Mon, 07 Mar 2022 01:19:33 -0800 (PST) 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; dkim=pass header.i=@linaro.org header.s=google header.b=gnQFlufo; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235102AbiCGDj6 (ORCPT + 99 others); Sun, 6 Mar 2022 22:39:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235006AbiCGDjw (ORCPT ); Sun, 6 Mar 2022 22:39:52 -0500 Received: from mail-oi1-x22d.google.com (mail-oi1-x22d.google.com [IPv6:2607:f8b0:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FEA14F9CF for ; Sun, 6 Mar 2022 19:38:57 -0800 (PST) Received: by mail-oi1-x22d.google.com with SMTP id 12so13873965oix.12 for ; Sun, 06 Mar 2022 19:38:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3GmDZYi4u1qi2UI5mnbc01oOxaZZdXpA01oXVaEo5vQ=; b=gnQFlufok1ukyNwqUHMx6eGHCZiKYgu2I5hjM9u4WIaIcnZus1X+uVPa+/6wAueX4G DQKwVTlhL/G4fI6VDNTiy+HHJZk4N0pz22fHR+kLmGUxsJo9Rd1q5r3HHYkJ4/GdXo5K XfkZf5i6nsfZvTZoZAvu0wzGMdZ53cjpOGp2XSXJTDVbJMit7H53GQnTFkD/iyItHosJ vJi2PeRS8k7pkWM4ppzPIADSIrqHCq5cty66Q87sYbc1y5nfnvfvdVoZKeJ2ZUdntizH ZKztB8nX42X0bx00EQ1kQb6t5UbLf47AF0L/QYGx6qyDhtyZYuJ/MsKGDY84HaouCRmu je3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3GmDZYi4u1qi2UI5mnbc01oOxaZZdXpA01oXVaEo5vQ=; b=pn3mX+iYUY32maj3/rg02MS8PtG1YEF77wvDPaKOYEOR9ikWNMn9wRiaLUgt2/V1iv TvxK9JqtzTKg1bfaX0sVjHPcWzeMXWYptMAnsHrQxTiG/NHms9yhP71oiYAMbUgf036/ Q5VfYPhrdegbnTMUYPr9cYCvd8RMRqZWMWHSoQm8x92LdfrrbXp+i7ZSkolgTv28vAz2 vlEeKKClz+PpSaeOPlcUjVWFnhgia3MTQnKZTyrRLUnFsV/L/XEdkJZHIPmMpHhTBPtm 3tvBT82G8QVh8Vs3pin1y6Hs8/XxQJZijwl0MAK7P8qHT9xxaCikVAxdirzta7ROnbAV WEAQ== X-Gm-Message-State: AOAM530zGgFjKcPi5COHo3E2X/RyyRFnF8YZYXPdlr5bHvwRkItgthQp K4pijif+ATKeBLM9QdD/bkGStw== X-Received: by 2002:a05:6808:11cd:b0:2d5:3f90:b9e with SMTP id p13-20020a05680811cd00b002d53f900b9emr5968578oiv.113.1646624336821; Sun, 06 Mar 2022 19:38:56 -0800 (PST) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id o2-20020a05687072c200b000d9ae3e1fabsm5005172oak.12.2022.03.06.19.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 06 Mar 2022 19:38:56 -0800 (PST) From: Bjorn Andersson To: Rob Herring , Andy Shevchenko , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Hans de Goede Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: [PATCH v4 3/7] usb: typec: mux: Check dev_set_name() return value Date: Sun, 6 Mar 2022 19:40:36 -0800 Message-Id: <20220307034040.1111107-3-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220307034040.1111107-1-bjorn.andersson@linaro.org> References: <20220307034040.1111107-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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. Reported-by: Andy Shevchenko Signed-off-by: Bjorn Andersson --- Changes since v3: - New patch drivers/usb/typec/mux.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c index c8340de0ed49..d2aaf294b649 100644 --- a/drivers/usb/typec/mux.c +++ b/drivers/usb/typec/mux.c @@ -131,8 +131,11 @@ typec_switch_register(struct device *parent, sw->dev.class = &typec_mux_class; sw->dev.type = &typec_switch_dev_type; sw->dev.driver_data = desc->drvdata; - dev_set_name(&sw->dev, "%s-switch", - desc->name ? desc->name : dev_name(parent)); + ret = dev_set_name(&sw->dev, "%s-switch", desc->name ? desc->name : dev_name(parent)); + if (ret) { + put_device(&sw->dev); + return ERR_PTR(ret); + } ret = device_add(&sw->dev); if (ret) { @@ -338,8 +341,11 @@ typec_mux_register(struct device *parent, const struct typec_mux_desc *desc) mux->dev.class = &typec_mux_class; mux->dev.type = &typec_mux_dev_type; mux->dev.driver_data = desc->drvdata; - dev_set_name(&mux->dev, "%s-mux", - desc->name ? desc->name : dev_name(parent)); + ret = dev_set_name(&mux->dev, "%s-mux", desc->name ? desc->name : dev_name(parent)); + if (ret) { + put_device(&mux->dev); + return ERR_PTR(ret); + } ret = device_add(&mux->dev); if (ret) { -- 2.33.1