From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.linuxfoundation.org ([140.211.169.12]:41574 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751027AbdKSKdx (ORCPT ); Sun, 19 Nov 2017 05:33:53 -0500 Subject: Patch "extcon: Remove potential problem when calling extcon_register_notifier()" has been added to the 4.9-stable tree To: cw00.choi@samsung.com, alexander.levin@verizon.com, gregkh@linuxfoundation.org Cc: , From: Date: Sun, 19 Nov 2017 11:33:10 +0100 Message-ID: <151108759021675@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org List-ID: This is a note to let you know that I've just added the patch titled extcon: Remove potential problem when calling extcon_register_notifier() to the 4.9-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: extcon-remove-potential-problem-when-calling-extcon_register_notifier.patch and it can be found in the queue-4.9 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let know about it. >>From foo@baz Sun Nov 19 11:32:28 CET 2017 From: Chanwoo Choi Date: Mon, 19 Dec 2016 21:02:33 +0900 Subject: extcon: Remove potential problem when calling extcon_register_notifier() From: Chanwoo Choi [ Upstream commit 01b4c9a1ae07a25d208cad0da7dd288007a22984 ] This patch removes the potential problem of extcon_register_notifier() when edev parameter is NULL. When edev is NULL, this function returns the first extcon device which includes the sepecific external connector of second paramter. But, it don't guarantee the same operation in all cases. To remove this confusion and potential problem, this patch fixes it. Signed-off-by: Chanwoo Choi Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/extcon/extcon.c | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -906,35 +906,16 @@ int extcon_register_notifier(struct extc unsigned long flags; int ret, idx = -EINVAL; - if (!nb) + if (!edev || !nb) return -EINVAL; - if (edev) { - idx = find_cable_index_by_id(edev, id); - if (idx < 0) - return idx; - - spin_lock_irqsave(&edev->lock, flags); - ret = raw_notifier_chain_register(&edev->nh[idx], nb); - spin_unlock_irqrestore(&edev->lock, flags); - } else { - struct extcon_dev *extd; - - mutex_lock(&extcon_dev_list_lock); - list_for_each_entry(extd, &extcon_dev_list, entry) { - idx = find_cable_index_by_id(extd, id); - if (idx >= 0) - break; - } - mutex_unlock(&extcon_dev_list_lock); - - if (idx >= 0) { - edev = extd; - return extcon_register_notifier(extd, id, nb); - } else { - ret = -ENODEV; - } - } + idx = find_cable_index_by_id(edev, id); + if (idx < 0) + return idx; + + spin_lock_irqsave(&edev->lock, flags); + ret = raw_notifier_chain_register(&edev->nh[idx], nb); + spin_unlock_irqrestore(&edev->lock, flags); return ret; } Patches currently in stable-queue which might be from cw00.choi@samsung.com are queue-4.9/extcon-remove-potential-problem-when-calling-extcon_register_notifier.patch queue-4.9/extcon-palmas-check-the-parent-instance-to-prevent-the-null.patch