Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2583216pxp; Mon, 7 Mar 2022 19:33:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyRqUnTuJIsqGVAim9CC1nNiRwiLG3oIrVLgcDKAmKbL+tzHJwSUij6vPNZSgzRvuvM9Vk3 X-Received: by 2002:a63:1803:0:b0:37e:d39e:949c with SMTP id y3-20020a631803000000b0037ed39e949cmr12475466pgl.100.1646710405398; Mon, 07 Mar 2022 19:33:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646710405; cv=none; d=google.com; s=arc-20160816; b=obPekYoUIysZM67k1s4E4QrMymMyraTp0TZjWJGnCnmoqq6w5rWrEV+4FipbGJ+Ev2 aBlsWfsUESfLlMrvw1jEGkkQphu8X3x+EQG0A+ZL/Su0ULzd9K4Dsu+rIQKK7Mdj2xxW /yqr3lmi8oQ9t596nlewlyfDS17v1vSx43ODtAamB2SBepK+b5YDJfb60QiUtf5mm5KO vBUbJhcrZkY6Ww5YAFNYHdHRi8CCmEGUnPK6SisZiA6RF9LjCFH70/cPCKQfQoYxlvXU h80gWMqGC3Vnue0uLzarDlwT5g0LVw8YQvgp91hnNAA0uk0Pv06T18RMPAfHzd0AhfMQ K9Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=cUcJgGkz9TsZGx+TT1/qFBPn7D4mofnDQ3W3dLGmk1g=; b=bta4K6GwFRsoWqnVovCTtKi1r2AA7gkiDhu9p1s9l1Llk4E8LsRYHP+AnDY8az9IXD QmMSPmvcdaupXNK4G4cUT1/bvLk+ZcSP9OJKzhVgRvTfLpubaMR316LdFsm6iVj8HufG DdJ+7+lYuXluxsRBnHrwRYVARMO9QNqlxHh9v69m5cG6haprtq7s0tlMhSYCHcpqK3Sb Cpp2fRJeGzehbPZSKZB9E9sS8rORuCF9LFkWmmQbN1wirEFVv+7T8d4BbRr9JcNkEV7g kucRsPDr6BDrziq2i7p9cXmKZLJ0rGvOMoW5AxxBJVbchBqpD/H3N7vxoJhWz132PuZo sSZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cw8u9u7f; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q4-20020a170902edc400b001518cb0179asi14962182plk.107.2022.03.07.19.32.52; Mon, 07 Mar 2022 19:33:25 -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=@intel.com header.s=Intel header.b=cw8u9u7f; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241542AbiCGKvG (ORCPT + 99 others); Mon, 7 Mar 2022 05:51:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51676 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242465AbiCGKtS (ORCPT ); Mon, 7 Mar 2022 05:49:18 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51227A0BF5; Mon, 7 Mar 2022 02:09:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1646647747; x=1678183747; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=8PFTkIqce0rP+0KbEpJbiB9sWz9SBA69Y1zamNvg0f4=; b=cw8u9u7f7159WZzX2d1h+tzfnd0vhsDVxpnRlElCpEucD8u10VhfcM9g 3XLWQvqtQKnKXUl/UnKv0AOSbEoC9TMtueLdASsZvJFewv+pTVdS58erB CCzreqxiI3UkBL/2PPI2NMgip79NqzFRPzLffBM2EutS0extYib4ijbjv 06387ymMKMMMx4SvATc69V15wgtpv9nA5Ln0B113dgG7tnHhSgJ9laV73 GFKjV/Ab4F4jMpG+aTaSxy1S0WogXw8gPX4LzWeaDLalagmqg3/N0Ek8l Ex7Y90MVgvzbdod4rNdKcMdP+1w34qdfLQL9sTcB+IXl4yyU93rGnehsv A==; X-IronPort-AV: E=McAfee;i="6200,9189,10278"; a="234961906" X-IronPort-AV: E=Sophos;i="5.90,161,1643702400"; d="scan'208";a="234961906" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 02:09:06 -0800 X-IronPort-AV: E=Sophos;i="5.90,161,1643702400"; d="scan'208";a="780273706" Received: from smile.fi.intel.com ([10.237.72.59]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Mar 2022 02:09:04 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.95) (envelope-from ) id 1nRAHr-00ChaN-5o; Mon, 07 Mar 2022 12:08:19 +0200 Date: Mon, 7 Mar 2022 12:08:18 +0200 From: Andy Shevchenko To: Bjorn Andersson Cc: Rob Herring , Daniel Scally , Heikki Krogerus , Sakari Ailus , "Rafael J. Wysocki" , Hans de Goede , linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Dmitry Baryshkov Subject: Re: [PATCH v4 3/7] usb: typec: mux: Check dev_set_name() return value Message-ID: References: <20220307034040.1111107-1-bjorn.andersson@linaro.org> <20220307034040.1111107-3-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220307034040.1111107-3-bjorn.andersson@linaro.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,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 On Sun, Mar 06, 2022 at 07:40:36PM -0800, Bjorn Andersson wrote: > It's possible that dev_set_name() returns -ENOMEM, catch and handle this. Thanks! Shouldn't we have a Fixes tag and be sent separately for this cycle? > 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)); We may use shorten form of the ternary ret = dev_set_name(&sw->dev, "%s-switch", desc->name ?: dev_name(parent)); at the same time, but it's up to you. Either way code looks good to me, Reviewed-by: Andy Shevchenko > + 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)); Ditto. > + if (ret) { > + put_device(&mux->dev); > + return ERR_PTR(ret); > + } > > ret = device_add(&mux->dev); > if (ret) { > -- > 2.33.1 > -- With Best Regards, Andy Shevchenko