Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2712693pxy; Mon, 3 May 2021 06:28:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwT/UdqpPRxz4tflHy53h3bwNPi/5bsMBexhd/XsBVbxERYXQF2GepC/SupLAwGbIxxcsuW X-Received: by 2002:a05:6402:b:: with SMTP id d11mr9521450edu.6.1620048503048; Mon, 03 May 2021 06:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620048503; cv=none; d=google.com; s=arc-20160816; b=qCOouRTNgGiBkTTici9khMPmdI0LdczcGvQcYxLq4zz7CNgzWvVy6yewMO/Dl8PnW6 pbpOtQnIyeBxJGldDTQELYYVmJiR3VN52wsHlfyxJgr3eONRoN97XmIicYs14B17aBo2 VVyYeybM8AnwTgbPCcZuvkk7DtG0DIrkqSrnLe+3ITqrp7NYiJAaEPTOvrXdgUmEIhzk ThDhPelF5gMKn7Syq7GMa802KVRcB9KadGHaRPJRPg4MZULK4vd5ICJagf7pam2KDB1r U91g/+qbPkSkDe/Z1iw3o/vY31075cYljKCa1By1TAZyT5oknhN3eWY2BQatY1tsnc12 Lfnw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=7FOnHgv5Zz9E87xmSCsAPakwMCdP93AyFYV1+fTbgbA=; b=mmswiOB2YC2GQW/QiF4UeufjsGK8H7Ey+PVpzXRVNUoKlI2I+ifAwhu26065y0t9IV V5nlgPAbfqWPiqBdeEXcRizJ16o399SAGXOrqU/GmTNfkBeQmW/1uLwzkoSvbHClA3Ek YbLAxu86I9q7S2bmLbQuhGCQo59LgLVzVk2j/Zr/mgR31xJSxUlsg9XKhvWOyfm5HBtx ddsSibU9jTrBSyklVVXOnM6nNvkVoy8Wee7VfyCYBJYancham5jNrvQGKi/z73SJGNsa V+KYzMVQbegIFeS+ShJQmZ/lPbvIktBIKj3QunnqiDPoMCpd8wuK5WHooYKX1XO9tny8 9Usw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=D9HgUkoc; 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 e18si7150046ejb.261.2021.05.03.06.27.52; Mon, 03 May 2021 06:28:23 -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=D9HgUkoc; 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 S233935AbhECMCs (ORCPT + 99 others); Mon, 3 May 2021 08:02:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:35894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232994AbhECMBm (ORCPT ); Mon, 3 May 2021 08:01:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B7288613B3; Mon, 3 May 2021 12:00:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043249; bh=Di+WpS/ABiYVHUnUEBWKmIW+FmwyWbd3DMqZd3Ghzv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D9HgUkocdgJicaORFRrnEGbd/rdBaJ67x5cv2NGFN3SwAJF9akb/OsWWElmRbt724 WL1dCBA3nWKJxHhR9D6yPrT4mnmeIvp4I4Kf34WZHqf5mxuf+/Ivu354xHSz0CQqce /+LZCJCBj/666jrN2LW71Q7U5prSjcc6o4YhuBOI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Mark Brown Subject: [PATCH 57/69] ASoC: cs43130: handle errors in cs43130_probe() properly Date: Mon, 3 May 2021 13:57:24 +0200 Message-Id: <20210503115736.2104747-58-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 Signed-off-by: Greg Kroah-Hartman --- 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.31.1