All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kernel-janitors@vger.kernel.org
Subject: re: blkcg: fix blkcg_policy_data allocation bug
Date: Mon, 20 Jul 2015 14:54:36 +0000	[thread overview]
Message-ID: <20150720145436.GA19257@mwanda> (raw)

Hello Tejun Heo,

The patch 06b285bd1125: "blkcg: fix blkcg_policy_data allocation bug"
from Jul 9, 2015, leads to the following static checker warning:

	block/blk-cgroup.c:1219 blkcg_policy_register()
	error: double unlock 'mutex:&blkcg_pol_mutex'

block/blk-cgroup.c
  1184          /* allocate and install cpd's */
  1185          if (pol->cpd_size) {
  1186                  list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
  1187                          struct blkcg_policy_data *cpd;
  1188  
  1189                          cpd = kzalloc(pol->cpd_size, GFP_KERNEL);
  1190                          if (!cpd) {
  1191                                  mutex_unlock(&blkcg_pol_mutex);
                                                      ^^^^^^^^^^^^^^^
Free.

  1192                                  goto err_free_cpds;
  1193                          }
  1194  
  1195                          blkcg->pd[pol->plid] = cpd;
  1196                          cpd->plid = pol->plid;
  1197                          pol->cpd_init_fn(blkcg);
  1198                  }
  1199          }
  1200  
  1201          mutex_unlock(&blkcg_pol_mutex);
  1202  
  1203          /* everything is in place, add intf files for the new policy */
  1204          if (pol->cftypes)
  1205                  WARN_ON(cgroup_add_legacy_cftypes(&blkio_cgrp_subsys,
  1206                                                    pol->cftypes));
  1207          mutex_unlock(&blkcg_pol_register_mutex);
  1208          return 0;
  1209  
  1210  err_free_cpds:
  1211          if (pol->cpd_size) {
  1212                  list_for_each_entry(blkcg, &all_blkcgs, all_blkcgs_node) {
  1213                          kfree(blkcg->pd[pol->plid]);
  1214                          blkcg->pd[pol->plid] = NULL;
  1215                  }
  1216          }
  1217          blkcg_policy[pol->plid] = NULL;
  1218  err_unlock:
  1219          mutex_unlock(&blkcg_pol_mutex);
                              ^^^^^^^^^^^^^^^
Double free.

  1220          mutex_unlock(&blkcg_pol_register_mutex);
  1221          return ret;
  1222  }
  1223  EXPORT_SYMBOL_GPL(blkcg_policy_register);

regards,
dan carpenter

             reply	other threads:[~2015-07-20 14:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 14:54 Dan Carpenter [this message]
2015-07-21 15:06 ` [PATCH block/for-linus] blkcg: fix double unlock in blkcg_policy_register() error path Tejun Heo
2015-07-21 15:06   ` Tejun Heo

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=20150720145436.GA19257@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.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.