Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2673961pxj; Mon, 31 May 2021 07:59:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhJH813N0OHfW/CmT3VbOpXEgqc1HEtBuMUbjaj8y8gNjOTZVFyyGMGgY/4dwO4NoVmPoi X-Received: by 2002:a17:906:6814:: with SMTP id k20mr2486154ejr.455.1622473185862; Mon, 31 May 2021 07:59:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622473185; cv=none; d=google.com; s=arc-20160816; b=t+RtQXq0kfQMA9ueXG5WYy9WWwgVhARMU3q56PNLcEgMNYKUq6jFkabbJrmE0YwvwW ITMAo/kxaaLbZd+yMocya4RHma1LZ4g8H18CGLddES0yurAvXPEUhCiWErgkjnqhwl7h c657XvHbilNlIsXViauKtetitNsjKVsOKxwL0VONr4paOvHg5z+x/xL4JEt3KGT4aGLc lJmKFKzritE5L7SoAPTRYzjCr2Ss4OzVwND1khDdeCRelsrJP9h4haRtzHui7DRkRFJa CS7ilU7dLnBbStZrxdtzemwhR2S+lSTGeDTaKg5hr1NxkTiBASdXAeZP/TkS6OMOuux7 WB0Q== 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=oE4csL41qSi3yQA/E3fjNcdikrS4hsg5ijZfvVDF+nc=; b=fTFdzMgdNX6ANCs1M1YYjCIElmKh/rEqsGU5NOSjMn06qU83ZUdhtKDkKVBxF2Agz9 lnu93QB9ubW5kjR2DtWgCU9HpuznL9l6BGFFlLZX/gZGdI4fKaL9sOkRflkVWu1MWELI Z1lndB/WRMhl/XECPuJGkZg7x6UcEJcgxFUgvkyS59lIKtWQOtB4C30NdG66l349zZTj 775/T2exa+hMQnBDoGHngoYZR67iu2VZQRqwBaPO6+/2ca2ZO0/ok86oPFjC5k61Y0ss Eg/HQuDI8d7Igd6TZcLJR2rPfVMNgMqV3WxMtnY5ziDjRnr6912K1+nCe7d1DYIIoCFK DnAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mgcyTCUs; 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 n15si12643114edt.229.2021.05.31.07.59.23; Mon, 31 May 2021 07:59:45 -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=mgcyTCUs; 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 S234448AbhEaO7n (ORCPT + 99 others); Mon, 31 May 2021 10:59:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:36868 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232691AbhEaOFW (ORCPT ); Mon, 31 May 2021 10:05:22 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 87F40613A9; Mon, 31 May 2021 13:38:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468307; bh=ZqLak8BtxpSBoSac6F+jFOun1e3iSVOTf+B9UAhpitk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mgcyTCUsz/9kpOl1a66AmNp/SWzGcxHpvWfno8qFE7UcVL4bzGJAwRtp50BKNwAbL aOE2w6CSMTQei0SZ8TJAmZZdkiBdoZDqcdQv5JW2H/3T9D8rOTts3FWAoFOjSDdnm6 AfsyOKUrRASVb/SwW603e2bC6fvDRU/WO+acvAKg= 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.10 159/252] ASoC: cs43130: handle errors in cs43130_probe() properly Date: Mon, 31 May 2021 15:13:44 +0200 Message-Id: <20210531130703.410683666@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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 bb46e993c353..8f70dee95878 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