Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp303046pxx; Thu, 29 Oct 2020 03:05:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0ht7ASoX5YGo1mRfTpwjx58IoJHHeXESvBsvWxZQ+/cihb9GNXbHnllijjR5I7BC/tP3x X-Received: by 2002:a17:906:cc50:: with SMTP id mm16mr3320869ejb.145.1603965929239; Thu, 29 Oct 2020 03:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603965929; cv=none; d=google.com; s=arc-20160816; b=gwYQjsEPGlc+0aokRlHotgEn1l/OyFKWFBcUdKIt99nRoKHRwQYEcTFahIyzVlrPIM sq89DZgnnygt4uE8ZYQeQq7lWuaL/gZaIr/YFhCPRezcAWbpVCtBqUNYsmcKRmznbcOZ JpDnQCIvzxAXzpVGICxWxCc0O7iVBE3C5ltJEMoK+/Eivq/IxP1hzTMEkjEdQsN6W9jK /rYInif8Q7xcIZv7EtNKLCHruhLwo5P7HVPHxQz+VWAfjEIzER8ChDptQuWNkykrnx7G 5KPOv11w0KTAwTTwj3GIb1WhqR8vqtOoOJpxQcf7w8vVhwQV4OCrE798Lg13hopLZIpf TVvA== 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 :ironport-sdr:ironport-sdr; bh=xON+RodOh+spO2E0mrtWWx31WFZrffZOoBzEDmE/Xb4=; b=phorWNby2er8CdUD1m/pOZ37Kq6pSl83ppnjH7q/mDyLXOzPY56DH0RgRBduTY6kM+ iI+yVF1ulzlinS3xiYie3o4mop75A0iKwpmn0827Vgwnqii5vty0zljdol0Z7GhlIdBV JYss3vSnvc5svI64do4OrbinUQVD6SjehiBmdoiVCQQ4hTHIQr+0oc/n5r2Fn0dFi7dL PPU9ZuRqlQdI3AY3Jlsk5RlK1Vv/+XZwC2kEYByTsEC0me4EQYJlDBRjtGbpZzijqoTk oGvAAXkNMU8trHPQqNnUP4X6cgUqL2S1BeNHC0BME+vNx4A7uia4UHjHdqAZH0ZQ7+yc jeww== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dx26si806049ejb.593.2020.10.29.03.05.06; Thu, 29 Oct 2020 03:05:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbgJ2Jz3 (ORCPT + 99 others); Thu, 29 Oct 2020 05:55:29 -0400 Received: from mga04.intel.com ([192.55.52.120]:30816 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726407AbgJ2JzZ (ORCPT ); Thu, 29 Oct 2020 05:55:25 -0400 IronPort-SDR: ne3wz/pK1Rxh1AJ2S8CFWeVkOIXX/ARz3BayEEIBKnFneMaNqu6+H9aAHrUWCxInUdVPSYl9Vo zZdNmvfSDq2w== X-IronPort-AV: E=McAfee;i="6000,8403,9788"; a="165821758" X-IronPort-AV: E=Sophos;i="5.77,429,1596524400"; d="scan'208";a="165821758" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2020 02:55:25 -0700 IronPort-SDR: Q+Pio9uByfj+iBhdCLq9bw2TgVj7/1aCdpKtn8td/LVCWx6Guvl3yLt99biztWdHj5dHUAAZk4 kLNzhRvswmvw== X-IronPort-AV: E=Sophos;i="5.77,429,1596524400"; d="scan'208";a="536607372" Received: from twinkler-lnx.jer.intel.com ([10.12.91.138]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2020 02:55:23 -0700 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next 3/3] mei: bus: deinitialize callback functions on init failure Date: Thu, 29 Oct 2020 11:54:44 +0200 Message-Id: <20201029095444.957924-4-tomas.winkler@intel.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: <20201029095444.957924-1-tomas.winkler@intel.com> References: <20201029095444.957924-1-tomas.winkler@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alexander Usyskin If the initialization procedure for receive or receive callback registration on the client bus has failed the caller can't re-run it. Deinitilize the callback pointers and cancel the work to allow the caller to retry. Signed-off-by: Alexander Usyskin Signed-off-by: Tomas Winkler --- drivers/misc/mei/bus.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c index 1a54bf3ed0c3..76aa0e93748a 100644 --- a/drivers/misc/mei/bus.c +++ b/drivers/misc/mei/bus.c @@ -370,8 +370,11 @@ int mei_cldev_register_rx_cb(struct mei_cl_device *cldev, mei_cldev_cb_t rx_cb) else ret = -ENODEV; mutex_unlock(&bus->device_lock); - if (ret && ret != -EBUSY) + if (ret && ret != -EBUSY) { + cancel_work_sync(&cldev->rx_work); + cldev->rx_cb = NULL; return ret; + } return 0; } @@ -405,8 +408,11 @@ int mei_cldev_register_notif_cb(struct mei_cl_device *cldev, mutex_lock(&bus->device_lock); ret = mei_cl_notify_request(cldev->cl, NULL, 1); mutex_unlock(&bus->device_lock); - if (ret) + if (ret) { + cancel_work_sync(&cldev->notif_work); + cldev->notif_cb = NULL; return ret; + } return 0; } -- 2.25.4