Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys/dev/dm



Le 19/08/2014 10:31, John Nemeth a écrit :
> On Aug 19,  6:50am, Maxime Villard wrote:
> } Le 18/08/2014 19:16, Alistair G. Crooks a écrit :
> } > 
> } > Module Name:      src
> } > Committed By:     agc
> } > Date:             Mon Aug 18 17:16:42 UTC 2014
> } > 
> } > Modified Files:
> } >   src/sys/dev/dm: dm_target_stripe.c
> } > 
> } > Log Message:
> } > Avoid a memory leak - from maxv
> } > 
> } > To generate a diff of this commit:
> } > cvs rdiff -u -r1.19 -r1.20 src/sys/dev/dm/dm_target_stripe.c
> } 
> } I have a doubt for this one.
> } 
> }     for (strpi = DM_STRIPE_DEV_OFFSET; strpi < strpc; strpi += 2) {
> }             printf("Stripe target device name %s -- offset %s\n",
> }                    argv[strpi], argv[strpi+1]);
> } 
> }             tlc = kmem_alloc(sizeof(*tlc), KM_NOSLEEP);
> }             if ((tlc->pdev = dm_pdev_insert(argv[strpi])) == NULL) {
> }                     kmem_free(tsc, sizeof(*tsc));
> } XXX                 kmem_free(tlc, sizeof(*tlc));
> }                     return ENOENT;
> }             }
> }             tlc->offset = atoi(argv[strpi+1]);
> } 
> }             /* Insert striping device to linked list. */
> } XXX         TAILQ_INSERT_TAIL(&tsc->stripe_devs, tlc, entries);
> }     }
> } 
> } The tlc's inserted into the list are not freed, are they?
> 
>      Notice the "return ENOENT" after the two calls to kmem_free().
> If the first XXX line is executed then the second XXX line won't be.

Yes, but that's a loop. The second XXX line may be reached several times,
before the first one returns ENOENT. And on that case the tlc's previously
allocated are not freed.

Unless I'm not reading clearly?




Home | Main Index | Thread Index | Old Index