Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2624451pxj; Mon, 31 May 2021 06:50:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyONh80LutYJYuividHCLDKm+0mfhHTHJUug6Gfi8C65wcBgJHrCzxgAKaUwx4vjgvVKXcX X-Received: by 2002:a17:906:5949:: with SMTP id g9mr6243741ejr.296.1622469022642; Mon, 31 May 2021 06:50:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469022; cv=none; d=google.com; s=arc-20160816; b=r/8Xd/XpRXHUITOclY6pXu3qZ+xeHcsBAWT9JYH3cOY076xVTbwKR4ck7nOyOBvcZm m8sFGNusX5ra9qRYXxCqtqVnAfqjUggb9NMLg5tW8gadRfF3VjsTFRx0t5NQ/2qsBXya PpvCMI18Q0SOJ1gz+s6PMoE1B19YkydH1VXl/LeSJBfKzAXODLUgaucWOUUeJJHDhdlZ +D5iPT/pmN9rxllX61YvFqywhEgazEZWu4WssKs7l2oj3XCrIoSshZf5ot/MWEs/8uPn +PEuOcco37yik5ZfI7YiEERWMPJm1uKbKLkjTwOjZbfcWG4LkuTAt9kO/Iqgh1YuV9L5 HKHg== 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=ueaQ+fCMge2JqfHszHbnnjHD0aFigV9rjuS118JuwIk=; b=aHTlqRyrjVdOtqbYohnX0GRCMVPK+50nh+Sku3GpKQbyiVZG8nGP973F+al5wiYIEZ iixYPUBd7M7z2y//8H4YIswHmxbipugSWmjQwgu3IHWaD8qYpsdoxm/krSqv/Xs2LoJI gFC45t9i4/9mU+TB8rCeJ8UlKb7Ts/QZwOEjtxx1xu8zh/0gaMpnFtFnSnz4hwoF1U/e FyFFJ5/pMBtFI79vc9MWmume/GkOShljAkwqIaEp7D9LWKKseZPdRuMXeDLLojiitX3Y ovvtTnpVQiQc5mkFtridK9bSKkYroDxGir/HCJTnx3pPfRbrGRStsJhD5j4jF4kXJZ1i 9z1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WOob0cTB; 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 s20si13376597ejb.555.2021.05.31.06.49.59; Mon, 31 May 2021 06:50:22 -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=WOob0cTB; 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 S232308AbhEaNsQ (ORCPT + 99 others); Mon, 31 May 2021 09:48:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:37634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232463AbhEaNd4 (ORCPT ); Mon, 31 May 2021 09:33:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A27A761438; Mon, 31 May 2021 13:24:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467486; bh=fZ7ZyR35+gTZDKlGqi1NIYsxIkTtZ7Fl1Oyo9dZ3W8I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WOob0cTBirBcMNWtDoL+KGQAe0rdmUqAZQgmgbmbJ6V1zjLwc3XbNq3I4l9gUSyny UNyTAi16NXaf9qVfUpzz9HE7Pcn8EHEqDyjpqxvmTuPaLd08f2ks/Kjt6kRYfYNcpU D5j7dHrdmbbIk95CdgnQNLJtLKz6oxHNbzDUNkS0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Brown , Sasha Levin Subject: [PATCH 4.19 084/116] ASoC: cs43130: handle errors in cs43130_probe() properly Date: Mon, 31 May 2021 15:14:20 +0200 Message-Id: <20210531130643.000410971@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 80dc42197154..cf29dec28b5e 100644 --- a/sound/soc/codecs/cs43130.c +++ b/sound/soc/codecs/cs43130.c @@ -1738,6 +1738,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}, @@ -2305,23 +2313,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