From 6c4936b6da4f828f193cebc14eb3991af5dc166f Mon Sep 17 00:00:00 2001 From: oster Date: Thu, 23 Mar 2006 03:43:54 +0000 Subject: This one is good for making one's brain hurt. Turns out that the original RAIDframe code had the same bug with dag_h being used when possibly NULL. Use dagList as the starting point for any potential dag_h's. Move the initialization of dag_h in this part to a little later. Loop now runs through in equivalent lock-step with the construction of the dagList earlier in the function. Addresses Coverity CID 1129 (id=6841 Run 5). --- sys/dev/raidframe/rf_aselect.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'sys/dev/raidframe') diff --git a/sys/dev/raidframe/rf_aselect.c b/sys/dev/raidframe/rf_aselect.c index 0dfe343e6f9..4c796feefa3 100644 --- a/sys/dev/raidframe/rf_aselect.c +++ b/sys/dev/raidframe/rf_aselect.c @@ -1,4 +1,4 @@ -/* $NetBSD: rf_aselect.c,v 1.23 2006/03/18 17:34:31 oster Exp $ */ +/* $NetBSD: rf_aselect.c,v 1.24 2006/03/23 03:43:54 oster Exp $ */ /* * Copyright (c) 1995 Carnegie-Mellon University. * All rights reserved. @@ -33,7 +33,7 @@ *****************************************************************************/ #include -__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.23 2006/03/18 17:34:31 oster Exp $"); +__KERNEL_RCSID(0, "$NetBSD: rf_aselect.c,v 1.24 2006/03/23 03:43:54 oster Exp $"); #include @@ -441,12 +441,6 @@ rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags) if ((numStripesBailed > 0) || (numStripeUnitsBailed > 0)) { stripeNum = 0; stripeUnitNum = 0; - if (dag_h->asmList) { - endASMList = dag_h->asmList; - while (endASMList->next) - endASMList = endASMList->next; - } else - endASMList = NULL; /* walk through io, stripe by stripe */ /* here we build up dag_h->asmList for this dag... we need all of these asm's to do the IO, and @@ -454,8 +448,19 @@ rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags) later time */ stripeFuncs = stripeFuncsList; failed_stripe = failed_stripes_list; + dagList = desc->dagList; + for (i = 0, asm_p = asmap; asm_p; asm_p = asm_p->next, i++) { - if (stripeFuncs->fp == NULL) { + + dag_h = dagList->dags; + if (dag_h->asmList) { + endASMList = dag_h->asmList; + while (endASMList->next) + endASMList = endASMList->next; + } else + endASMList = NULL; + + if (stripeFuncs->fp == NULL) { numStripeUnits = asm_p->numStripeUnitsAccessed; /* walk through stripe, stripe unit by * stripe unit */ @@ -495,6 +500,7 @@ rf_SelectAlgorithm(RF_RaidAccessDesc_t *desc, RF_RaidAccessFlags_t flags) stripeNum++; failed_stripe = failed_stripe->next; } + dagList = dagList->next; /* need to move in stride with stripeFuncs */ stripeFuncs = stripeFuncs->next; } RF_ASSERT(stripeNum == numStripesBailed); -- cgit