From patchwork Fri Apr 22 22:23:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 12824290 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4BBFC4332F for ; Fri, 22 Apr 2022 22:55:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233666AbiDVW5x (ORCPT ); Fri, 22 Apr 2022 18:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51348 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234219AbiDVW5m (ORCPT ); Fri, 22 Apr 2022 18:57:42 -0400 Received: from mail-oi1-x22c.google.com (mail-oi1-x22c.google.com [IPv6:2607:f8b0:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78E9935C5F4 for ; Fri, 22 Apr 2022 15:21:54 -0700 (PDT) Received: by mail-oi1-x22c.google.com with SMTP id e4so10593218oif.2 for ; Fri, 22 Apr 2022 15:21:54 -0700 (PDT) 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=AvSAQb1M8ai7iREtClhTlQbpfuCOvIwvoizOPDtnCrk=; b=Pc1e+PMZm5IuYicnb0WwTJ3NxS7TWcDp5tMa6jMLdMKAY3An0CjGAK0elizA3QrGdx qzxqjjVPtpGIT6IPsJIq1xPrBEMGIwCLBxMej9K4Y+EHPh8ksv960DhiDp443oAUcbFZ Jhsny1PFJ8tHy9iAkzQntJe638zmBWWED/CGHiAsKTL/om+PCaUq7KuJMxwxuIDtdN+z b24DjqO1UN/wg00srUSnjInLBJasjhNV6itXuEF4Xm2wa8jd5dq6Aeb5ibdQYQLy6MJu UaPkjfulA0/O5DsIxHPt15xV9ek4CamZlac5+XwtbU0OWOkFk0ROC2t/7ED58vXNdNM2 saOw== 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=AvSAQb1M8ai7iREtClhTlQbpfuCOvIwvoizOPDtnCrk=; b=VK+yYjV/PH+DuN9Ntvft+j3oUZwXIw0xiP/L5olNcNSALX1+7DmLJZnfQru49pIFgE 3lfXAuKe+oxmdq+N1Pt1Ks8SedkEuEbE2yix9x0B3vGtI6YPcj42jlLTQHj4oEogco2p K6Az7YbN/++QToQolgE/AnCnnHbxTxmQkrMA/uVWhUkdv/iHe4GcGi4Fz/LTab8AEvot MrMeSi0i9+69zByKfNMMOYFZa/unOZbO39RuKVEZ1uDBNwxv34t5EwDqhMEkk1pzUMgG NOaoUvZpig/GxzPrwsBcxvHdxBjjWlt5gNtlbUYQVY8nluVpLAHL5AUg6ukCIDmbXr36 FIkg== X-Gm-Message-State: AOAM531RT7IqFSGTCwlyM0gqBrnq6snWM8UGKMWsbuVcmm4s8Pao0JuD u0sOF6TGL4EcdfIDwTdAbevMYA== X-Google-Smtp-Source: ABdhPJxPQFhhi1f//zKscwPmmuTNsN+HkKo9ZZPLpV1bgBPsKMaslivRlGVFdAXX/APr6Tx55vb/oQ== X-Received: by 2002:a05:6808:3b8:b0:322:a783:8fc8 with SMTP id n24-20020a05680803b800b00322a7838fc8mr7584151oie.189.1650666113629; Fri, 22 Apr 2022 15:21:53 -0700 (PDT) Received: from ripper.. ([2600:1700:a0:3dc8:205:1bff:fec0:b9b3]) by smtp.gmail.com with ESMTPSA id js4-20020a056870bac400b000e687cdf5adsm1049224oab.55.2022.04.22.15.21.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 15:21:53 -0700 (PDT) From: Bjorn Andersson To: Greg Kroah-Hartman , Rob Herring , Krzysztof Kozlowski , 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 Subject: [PATCH v5 3/7] usb: typec: mux: Check dev_set_name() return value Date: Fri, 22 Apr 2022 15:23:47 -0700 Message-Id: <20220422222351.1297276-4-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220422222351.1297276-1-bjorn.andersson@linaro.org> References: <20220422222351.1297276-1-bjorn.andersson@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org It's possible that dev_set_name() returns -ENOMEM, catch and handle this. Fixes: 3370db35193b ("usb: typec: Registering real device entries for the muxes") Reported-by: Andy Shevchenko Acked-by: Heikki Krogerus Signed-off-by: Bjorn Andersson Reviewed-by: Andy Shevchenko --- Changes since v4: - Added Fixes tag 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) {