Re: [PATCH] scsi: advansys: fix uninitialized data access

From: Martin K. Petersen
Date: Tue Apr 04 2017 - 19:40:44 EST


Arnd Bergmann <arnd@xxxxxxxx> writes:

Arnd,

> drivers/scsi/advansys.c: In function 'AscMsgOutSDTR':
> drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> ((ushort)s_buffer[i + 1] << 8) | s_buffer[i]);
> ^
> drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+5)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> drivers/scsi/advansys.c:3860:26: error: '*((void *)&sdtr_buf+7)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> The code has existed in this exact form at least since v2.6.12, and the
> warning seems correct. This uses named initializers to ensure we initialize
> all members of the structure.
> (uchar *)&sdtr_buf,

Applied to 4.12/scsi-queue, thanks!

--
Martin K. Petersen Oracle Linux Engineering