svn commit: r226398 - head/sys/dev/iicbus
Pawel Jakub Dawidek
pjd at FreeBSD.org
Sun Oct 16 16:02:08 UTC 2011
On Sat, Oct 15, 2011 at 03:57:56PM +0000, Christian Brueffer wrote:
> Author: brueffer
> Date: Sat Oct 15 15:57:55 2011
> New Revision: 226398
> URL: http://svn.freebsd.org/changeset/base/226398
>
> Log:
> Properly free resources in an error case.
>
> CID: 4203
> Found with: Coverity Prevent(tm)
> MFC after: 1 week
>
> Modified:
> head/sys/dev/iicbus/iic.c
>
> Modified: head/sys/dev/iicbus/iic.c
> ==============================================================================
> --- head/sys/dev/iicbus/iic.c Sat Oct 15 15:21:33 2011 (r226397)
> +++ head/sys/dev/iicbus/iic.c Sat Oct 15 15:57:55 2011 (r226398)
> @@ -348,8 +348,10 @@ iicioctl(struct cdev *dev, u_long cmd, c
> buf = malloc(sizeof(*d->msgs) * d->nmsgs, M_TEMP, M_WAITOK);
> usrbufs = malloc(sizeof(void *) * d->nmsgs, M_TEMP, M_ZERO | M_WAITOK);
> error = copyin(d->msgs, buf, sizeof(*d->msgs) * d->nmsgs);
> - if (error)
> + if (error) {
> + free(usrbufs, M_TEMP);
> break;
> + }
I think that better fix is to move usrbufs allocation after copyin(), as
usrbufs is not used there.
--
Pawel Jakub Dawidek http://www.wheelsystems.com
FreeBSD committer http://www.FreeBSD.org
Am I Evil? Yes, I Am! http://yomoli.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/svn-src-all/attachments/20111016/73296479/attachment.pgp
More information about the svn-src-all
mailing list