Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2743595pxj; Mon, 31 May 2021 09:37:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlH1fdo8YVQStpxNR4xLxc7aZx4K3oqw0gDscbfjHfU/O+HBWtWQmiGKLwUseIWI8nucFk X-Received: by 2002:a17:907:c1c:: with SMTP id ga28mr24517784ejc.320.1622479053096; Mon, 31 May 2021 09:37:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622479053; cv=none; d=google.com; s=arc-20160816; b=c+s2WmVs0xZXLnlCLHn6tbDTbkbpGUfMWZcln6Q/jFxTazqhh/xLlQD/3JCTSAfwns E2845mO5syHJdfCPq0bPe50M5ziwclnRv/1LlMgYft3Ew4Y0viWTzv6Wa0DoOPCKlIQn 9F+L69YtcU1jcOScKwq0RZHTvCMU9Ums5CWp4RcoE9YNDl2hm8prl86XfKEfk2reIkm9 3g9pkORyq16cAew3sd9RRRTYMiVlmcXwO8Hqc/PClbHF6iD8OS4t+ZdbLbfeqa7AH5f2 8Dxhs1ygWscexvPsn9Yi4ngJw2Hl746gz29MCchk78xOP6fwzkqO0bgRLZsuq80wIDer DX/w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Y0emvhz53hRYyD30H2AyPBPcU6wzSkCdfEUzVbg9Whk=; b=QYpPhaL6kw5ejCGfYuX+fU1Q8e4kseizBygaEjGQCM1CIkprBORsH0521PkeyjSTFC AvaT/VG6Vaw2SaVzoMHqv+ggo8f84of1bvcCH6Sw2ygdksjho4yIFdigpm73H8/47X/5 RNVdnN+YUV8aOSGGEYR4fQtQJWpHgfwr+BXCs+uOKHO6ZLjdTJ+FeSSIBJyj9Om2aHGl KDNeOEt/TScJkf7gh+kI3BQPpADXL9G0orfH2463bHFO4ttA4rNtvEDJVW7Y74bVDXPv FXViomFRKklIcWKvBzElC8wGE4dysNd/T3EyRU0mj5NE5wSytET/AyCOAFTOHpIaOkP3 u1jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EVeISOl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p3si15553499ejy.228.2021.05.31.09.37.07; Mon, 31 May 2021 09:37:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EVeISOl5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234069AbhEaQhl (ORCPT + 99 others); Mon, 31 May 2021 12:37:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:40312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbhEaOtN (ORCPT ); Mon, 31 May 2021 10:49:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5E7C4613EE; Mon, 31 May 2021 13:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622469416; bh=A2WEoULKf3UGbZpFCnzA4fcaKOiqPYWyi3rwCwUC4BI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EVeISOl5gSxo5V5/nDr8sr4SaSwuhTcK6TUUPuobaU5EDTIEZ3q50kPoRZKhHN6uw WXHax6u5iCa9tVHAiQaxGYRbV9M5WSAFsUgCJPLXbybHq0upe3jj1Fz1CPsCQ5TUM7 UVaOuxRwe69nK4FaLBE7PBn2/Rmo7Zua80pNm/+U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Sasha Levin Subject: [PATCH 5.12 189/296] ASoC: cs43130: handle errors in cs43130_probe() properly Date: Mon, 31 May 2021 15:14:04 +0200 Message-Id: <20210531130710.222986403@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130703.762129381@linuxfoundation.org> References: <20210531130703.762129381@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman [ Upstream commit 2da441a6491d93eff8ffff523837fd621dc80389 ] cs43130_probe() does not do any valid error checking of things it initializes, OR what it does, it does not unwind properly if there are errors. Fix this up by moving the sysfs files to an attribute group so the driver core will correctly add/remove them all at once and handle errors with them, and correctly check for creating a new workqueue and unwinding if that fails. Cc: Mark Brown Link: https://lore.kernel.org/r/20210503115736.2104747-58-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- sound/soc/codecs/cs43130.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sound/soc/codecs/cs43130.c b/sound/soc/codecs/cs43130.c index c2b6f0ae6d57..80cd3ea0c157 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -1735,6 +1735,14 @@ static DEVICE_ATTR(hpload_dc_r, 0444, cs43130_show_dc_r, NULL); static DEVICE_ATTR(hpload_ac_l, 0444, cs43130_show_ac_l, NULL); static DEVICE_ATTR(hpload_ac_r, 0444, cs43130_show_ac_r, NULL); +static struct attribute *hpload_attrs[] = { + &dev_attr_hpload_dc_l.attr, + &dev_attr_hpload_dc_r.attr, + &dev_attr_hpload_ac_l.attr, + &dev_attr_hpload_ac_r.attr, +}; +ATTRIBUTE_GROUPS(hpload); + static struct reg_sequence hp_en_cal_seq[] = { {CS43130_INT_MASK_4, CS43130_INT_MASK_ALL}, {CS43130_HP_MEAS_LOAD_1, 0}, @@ -2302,23 +2310,15 @@ static int cs43130_probe(struct snd_soc_component *component) cs43130->hpload_done = false; if (cs43130->dc_meas) { - ret = device_create_file(component->dev, &dev_attr_hpload_dc_l); - if (ret < 0) - return ret; - - ret = device_create_file(component->dev, &dev_attr_hpload_dc_r); - if (ret < 0) - return ret; - - ret = device_create_file(component->dev, &dev_attr_hpload_ac_l); - if (ret < 0) - return ret; - - ret = device_create_file(component->dev, &dev_attr_hpload_ac_r); - if (ret < 0) + ret = sysfs_create_groups(&component->dev->kobj, hpload_groups); + if (ret) return ret; cs43130->wq = create_singlethread_workqueue("cs43130_hp"); + if (!cs43130->wq) { + sysfs_remove_groups(&component->dev->kobj, hpload_groups); + return -ENOMEM; + } INIT_WORK(&cs43130->work, cs43130_imp_meas); } -- 2.30.2