All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: [thierryreding:for-5.5/dp 79/124] drivers/memory/core.c:79 of_memory_controller_get() error: double unlock 'mutex:&controllers_lock'
Date: Mon, 21 Oct 2019 10:54:28 +0300	[thread overview]
Message-ID: <20191021075428.GA10833@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 4157 bytes --]

tree:   https://github.com/thierryreding/linux for-5.5/dp
head:   c80326581f9bf16162c2f3d5dcc5f006bbc93f86
commit: 429583789bbda8c3ef59f9b6c33fb483145752a4 [79/124] memory: Introduce memory controller mini-framework

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/memory/core.c:79 of_memory_controller_get() error: double unlock 'mutex:&controllers_lock'

Old smatch warnings:
include/linux/compiler.h:226 __write_once_size() warn: potential memory corrupting cast 8 vs 4 bytes

# https://github.com/thierryreding/linux/commit/429583789bbda8c3ef59f9b6c33fb483145752a4
git remote add thierryreding https://github.com/thierryreding/linux
git remote update thierryreding
git checkout 429583789bbda8c3ef59f9b6c33fb483145752a4
vim +79 drivers/memory/core.c

429583789bbda8 Thierry Reding 2019-08-20  41  static struct memory_controller *
429583789bbda8 Thierry Reding 2019-08-20  42  of_memory_controller_get(struct device *dev, struct device_node *np,
429583789bbda8 Thierry Reding 2019-08-20  43  			 const char *con_id)
429583789bbda8 Thierry Reding 2019-08-20  44  {
429583789bbda8 Thierry Reding 2019-08-20  45  	const char *cells = "#memory-controller-cells";
429583789bbda8 Thierry Reding 2019-08-20  46  	const char *names = "memory-controller-names";
429583789bbda8 Thierry Reding 2019-08-20  47  	const char *prop = "memory-controllers";
429583789bbda8 Thierry Reding 2019-08-20  48  	struct memory_controller *mc;
429583789bbda8 Thierry Reding 2019-08-20  49  	struct of_phandle_args args;
429583789bbda8 Thierry Reding 2019-08-20  50  	int index = 0, err;
429583789bbda8 Thierry Reding 2019-08-20  51  
429583789bbda8 Thierry Reding 2019-08-20  52  	if (con_id) {
429583789bbda8 Thierry Reding 2019-08-20  53  		index = of_property_match_string(np, names, con_id);
429583789bbda8 Thierry Reding 2019-08-20  54  		if (index < 0)
429583789bbda8 Thierry Reding 2019-08-20  55  			return ERR_PTR(index);
429583789bbda8 Thierry Reding 2019-08-20  56  	}
429583789bbda8 Thierry Reding 2019-08-20  57  
429583789bbda8 Thierry Reding 2019-08-20  58  	err = of_parse_phandle_with_args(np, prop, cells, index, &args);
429583789bbda8 Thierry Reding 2019-08-20  59  	if (err) {
429583789bbda8 Thierry Reding 2019-08-20  60  		if (err == -ENOENT)
429583789bbda8 Thierry Reding 2019-08-20  61  			err = -ENODEV;
429583789bbda8 Thierry Reding 2019-08-20  62  
429583789bbda8 Thierry Reding 2019-08-20  63  		return ERR_PTR(err);
429583789bbda8 Thierry Reding 2019-08-20  64  	}
429583789bbda8 Thierry Reding 2019-08-20  65  
429583789bbda8 Thierry Reding 2019-08-20  66  	mutex_lock(&controllers_lock);
429583789bbda8 Thierry Reding 2019-08-20  67  
429583789bbda8 Thierry Reding 2019-08-20  68  	list_for_each_entry(mc, &controllers, list) {
429583789bbda8 Thierry Reding 2019-08-20  69  		if (mc->dev && mc->dev->of_node == args.np) {
429583789bbda8 Thierry Reding 2019-08-20  70  			kref_get(&mc->ref);
429583789bbda8 Thierry Reding 2019-08-20  71  			mutex_unlock(&controllers_lock);
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

429583789bbda8 Thierry Reding 2019-08-20  72  			goto unlock;
429583789bbda8 Thierry Reding 2019-08-20  73  		}
429583789bbda8 Thierry Reding 2019-08-20  74  	}
429583789bbda8 Thierry Reding 2019-08-20  75  
429583789bbda8 Thierry Reding 2019-08-20  76  	mc = ERR_PTR(-EPROBE_DEFER);
429583789bbda8 Thierry Reding 2019-08-20  77  
429583789bbda8 Thierry Reding 2019-08-20  78  unlock:
429583789bbda8 Thierry Reding 2019-08-20 @79  	mutex_unlock(&controllers_lock);
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429583789bbda8 Thierry Reding 2019-08-20  80  	of_node_put(args.np);
429583789bbda8 Thierry Reding 2019-08-20  81  	return mc;
429583789bbda8 Thierry Reding 2019-08-20  82  }

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: [thierryreding:for-5.5/dp 79/124] drivers/memory/core.c:79 of_memory_controller_get() error: double unlock 'mutex:&controllers_lock'
Date: Mon, 21 Oct 2019 10:54:28 +0300	[thread overview]
Message-ID: <20191021075428.GA10833@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 4157 bytes --]

tree:   https://github.com/thierryreding/linux for-5.5/dp
head:   c80326581f9bf16162c2f3d5dcc5f006bbc93f86
commit: 429583789bbda8c3ef59f9b6c33fb483145752a4 [79/124] memory: Introduce memory controller mini-framework

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
drivers/memory/core.c:79 of_memory_controller_get() error: double unlock 'mutex:&controllers_lock'

Old smatch warnings:
include/linux/compiler.h:226 __write_once_size() warn: potential memory corrupting cast 8 vs 4 bytes

# https://github.com/thierryreding/linux/commit/429583789bbda8c3ef59f9b6c33fb483145752a4
git remote add thierryreding https://github.com/thierryreding/linux
git remote update thierryreding
git checkout 429583789bbda8c3ef59f9b6c33fb483145752a4
vim +79 drivers/memory/core.c

429583789bbda8 Thierry Reding 2019-08-20  41  static struct memory_controller *
429583789bbda8 Thierry Reding 2019-08-20  42  of_memory_controller_get(struct device *dev, struct device_node *np,
429583789bbda8 Thierry Reding 2019-08-20  43  			 const char *con_id)
429583789bbda8 Thierry Reding 2019-08-20  44  {
429583789bbda8 Thierry Reding 2019-08-20  45  	const char *cells = "#memory-controller-cells";
429583789bbda8 Thierry Reding 2019-08-20  46  	const char *names = "memory-controller-names";
429583789bbda8 Thierry Reding 2019-08-20  47  	const char *prop = "memory-controllers";
429583789bbda8 Thierry Reding 2019-08-20  48  	struct memory_controller *mc;
429583789bbda8 Thierry Reding 2019-08-20  49  	struct of_phandle_args args;
429583789bbda8 Thierry Reding 2019-08-20  50  	int index = 0, err;
429583789bbda8 Thierry Reding 2019-08-20  51  
429583789bbda8 Thierry Reding 2019-08-20  52  	if (con_id) {
429583789bbda8 Thierry Reding 2019-08-20  53  		index = of_property_match_string(np, names, con_id);
429583789bbda8 Thierry Reding 2019-08-20  54  		if (index < 0)
429583789bbda8 Thierry Reding 2019-08-20  55  			return ERR_PTR(index);
429583789bbda8 Thierry Reding 2019-08-20  56  	}
429583789bbda8 Thierry Reding 2019-08-20  57  
429583789bbda8 Thierry Reding 2019-08-20  58  	err = of_parse_phandle_with_args(np, prop, cells, index, &args);
429583789bbda8 Thierry Reding 2019-08-20  59  	if (err) {
429583789bbda8 Thierry Reding 2019-08-20  60  		if (err == -ENOENT)
429583789bbda8 Thierry Reding 2019-08-20  61  			err = -ENODEV;
429583789bbda8 Thierry Reding 2019-08-20  62  
429583789bbda8 Thierry Reding 2019-08-20  63  		return ERR_PTR(err);
429583789bbda8 Thierry Reding 2019-08-20  64  	}
429583789bbda8 Thierry Reding 2019-08-20  65  
429583789bbda8 Thierry Reding 2019-08-20  66  	mutex_lock(&controllers_lock);
429583789bbda8 Thierry Reding 2019-08-20  67  
429583789bbda8 Thierry Reding 2019-08-20  68  	list_for_each_entry(mc, &controllers, list) {
429583789bbda8 Thierry Reding 2019-08-20  69  		if (mc->dev && mc->dev->of_node == args.np) {
429583789bbda8 Thierry Reding 2019-08-20  70  			kref_get(&mc->ref);
429583789bbda8 Thierry Reding 2019-08-20  71  			mutex_unlock(&controllers_lock);
                                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

429583789bbda8 Thierry Reding 2019-08-20  72  			goto unlock;
429583789bbda8 Thierry Reding 2019-08-20  73  		}
429583789bbda8 Thierry Reding 2019-08-20  74  	}
429583789bbda8 Thierry Reding 2019-08-20  75  
429583789bbda8 Thierry Reding 2019-08-20  76  	mc = ERR_PTR(-EPROBE_DEFER);
429583789bbda8 Thierry Reding 2019-08-20  77  
429583789bbda8 Thierry Reding 2019-08-20  78  unlock:
429583789bbda8 Thierry Reding 2019-08-20 @79  	mutex_unlock(&controllers_lock);
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
429583789bbda8 Thierry Reding 2019-08-20  80  	of_node_put(args.np);
429583789bbda8 Thierry Reding 2019-08-20  81  	return mc;
429583789bbda8 Thierry Reding 2019-08-20  82  }

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

             reply	other threads:[~2019-10-21  7:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-21  7:54 Dan Carpenter [this message]
2019-10-21  7:54 ` [thierryreding:for-5.5/dp 79/124] drivers/memory/core.c:79 of_memory_controller_get() error: double unlock 'mutex:&controllers_lock' Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191021075428.GA10833@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.