Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2705154pxj; Mon, 31 May 2021 08:41:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwKkiEnsWE4wEVPjs0+/pe1sL6nHg3UiqRnaZm2BoZPPExmyL4HA+XPU+LxFvfuA46g7y57 X-Received: by 2002:a5d:89ce:: with SMTP id a14mr17498207iot.82.1622475661547; Mon, 31 May 2021 08:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475661; cv=none; d=google.com; s=arc-20160816; b=OpcyfqWC8yy5L63EK/FgRqgVOIXR78/O0ohAg7Yg2TwRVCpgXLV+DPiW8DvWJcm/Cw /3hl9KKd8NexIcDiZOsyuUQChzO0LKqYnBZYWKy11xr0Pc0olowGkhUhzOO6phZVctFY lhLrEruMimEoYUWkM7lFed3KaZjjK94iwg6oDP7uFH0l1FcNJ0wa2cXD38x1qhYgBAiN 5l/DTHuqaZf8mxwSLVB+S/nxhsK4AuXuc7x77VxUhOlpNogJVAhNUGNDbiJu6PivRnuz v1t8vCtitskjU9g8NpWig79/hMNw/gKZ9/wzLg+7hARVK6Kwg1oC0DyUrs52Y9Y8lZQA AUdg== 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=rRbqXJ2kaFqLs5FOsUzujL6+7zeXz2in/uFFXVFLnn0L0E1RnyI9Mbd9PjhV499Srk wJzcJZlLzbuhfNK96TJ3LfpOr1kyLfKcvtvbCzL3dD/fsJqSiObim/VzkYIDFquhKOFw 5HnDxPjw5ToNVn9oFTKotZTfmI3CSooKT/n1aG7ah71fsFW3KFo976vSxxFFyfAvwovE C7vIV+guDeH2mUFedGwhhZdiHPnLE7uV30Raxec6ziXqe8x0MJS5fl90lvMjtSa3651+ bfm8sNCSUS/3Nf42LrC73mEVR8B0FpzBTrGm66WaxLmNVICQnDKD3VFi7Q2m5HIPEdAz swTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=isQrZXwU; 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 w13si6198713jao.90.2021.05.31.08.40.48; Mon, 31 May 2021 08:41:01 -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=isQrZXwU; 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 S232880AbhEaPlz (ORCPT + 99 others); Mon, 31 May 2021 11:41:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:48840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232246AbhEaOX1 (ORCPT ); Mon, 31 May 2021 10:23:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3B2C9619FE; Mon, 31 May 2021 13:45:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468747; bh=ZqLak8BtxpSBoSac6F+jFOun1e3iSVOTf+B9UAhpitk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=isQrZXwUIYkejHuA+6tRcSKf5UtCGUc2YjXDZGTjO6WgyOJLH0r6/SHYkhweUeeEa gOgnJokoRGTk/ezwbjqDCKiPhmviK7h4zs33QE7Hi1TfJMrZWf4SKarUcJGD17b/8C Kmj8eMjDiHs/GnM7BbEYvN+pkhCbTMfeC0RF2Izg= 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.4 112/177] ASoC: cs43130: handle errors in cs43130_probe() properly Date: Mon, 31 May 2021 15:14:29 +0200 Message-Id: <20210531130651.783463399@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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