Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Apr 2016 14:32:50 -0500
From:      Pedro Giffuni <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r297527 - head/sys/cam/scsi
Message-ID:  <57016FE2.1070607@FreeBSD.org>
In-Reply-To: <201604031638.u33GcGsa092204@repo.freebsd.org>
References:  <201604031638.u33GcGsa092204@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help


On 03/04/2016 11:38, Pedro F. Giffuni wrote:
> Author: pfg
> Date: Sun Apr  3 16:38:15 2016
> New Revision: 297527
> URL: https://svnweb.freebsd.org/changeset/base/297527
>
> Log:
>    chdone(): Prevent returning uninitialized scalar value.
>    
>    If there is an error different from ERESTART, there is some
>    chance that we may end up accessing an uninitialized value. This
>    doesn't seem likely/possible but initialize announce_buf[0],
>    just in case.
>    
>    CID:	1006486
>
> Modified:
>    head/sys/cam/scsi/scsi_ch.c
>
> Modified: head/sys/cam/scsi/scsi_ch.c
> ==============================================================================
> --- head/sys/cam/scsi/scsi_ch.c	Sun Apr  3 16:25:51 2016	(r297526)
> +++ head/sys/cam/scsi/scsi_ch.c	Sun Apr  3 16:38:15 2016	(r297527)
> @@ -651,6 +651,7 @@ chdone(struct cam_periph *periph, union
>   		} else {
>   			int error;
>   
> +			announce_buf[0] = '\0';
>   			error = cherror(done_ccb, CAM_RETRY_SELTO,
>   					SF_RETRY_UA | SF_NO_PRINT);
>   			/*
>

This one is rather tricky ...
I wanted to play it safe so I initialized it here but I think that:
1) The late initialization in line 718 is now reduntant.
2) I could have instead moved the initialization in line 718 down one 
loop and
it would have had the same effect. The code would be more difficult to
understand if I had done it though.

Perhaps someone more familiar with the code wants to review this (I tried
with the author but he didn't reply and this code is old so I don't 
blame him).

Pedro.





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?57016FE2.1070607>