linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: md/raid5: Use conf->device_lock protect changing of multi-thread resources.
@ 2013-11-22 16:10 Ben Hutchings
  2013-11-25  0:16 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Hutchings @ 2013-11-22 16:10 UTC (permalink / raw)
  To: majianpeng, NeilBrown; +Cc: linux-raid

Coverity reported a new defect after this change (commit 60aaf9338545) -
passing a singleton pointer as the worker_groups parameter to
alloc_thread_groups() which expects an array pointer.  But actually it
looks like it should still be a singleton pointer and
alloc_thread_groups() is broken:

-       conf->worker_groups = kzalloc(sizeof(struct r5worker_group) *
-                               conf->group_cnt, GFP_NOIO);
-       if (!conf->worker_groups || !workers) {
+       workers = kzalloc(size * *group_cnt, GFP_NOIO);
+       *worker_groups = kzalloc(sizeof(struct r5worker_group) *
+                               *group_cnt, GFP_NOIO);
+       if (!*worker_groups || !workers) {
                kfree(workers);
-               kfree(conf->worker_groups);
-               conf->worker_groups = NULL;
+               kfree(*worker_groups);
                return -ENOMEM;
        }
 
-       for (i = 0; i < conf->group_cnt; i++) {
+       for (i = 0; i < *group_cnt; i++) {
                struct r5worker_group *group;
 
-               group = &conf->worker_groups[i];
+               group = worker_groups[i];

This assignment should, I think, be:

		group = &(*worker_groups)[i];

or equivalently:

		group = *worker_groups + i;

Ben.

-- 
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-11-25  0:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-22 16:10 md/raid5: Use conf->device_lock protect changing of multi-thread resources Ben Hutchings
2013-11-25  0:16 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).