* [PATCH] sd: fix uninitialized variable access in error handling
@ 2016-10-21 15:32 Arnd Bergmann
2016-10-21 20:48 ` Shaun Tancheff
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2016-10-21 15:32 UTC (permalink / raw)
To: James E.J. Bottomley, Martin K. Petersen
Cc: Arnd Bergmann, Hannes Reinecke, Shaun Tancheff, Jens Axboe,
Damien Le Moal, linux-scsi, linux-kernel
If sd_zbc_report_zones fails, the check for 'zone_blocks == 0'
later in the function accesses uninitialized data:
drivers/scsi/sd_zbc.c: In function ‘sd_zbc_read_zones’:
drivers/scsi/sd_zbc.c:520:7: error: ‘zone_blocks’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
This sets it to zero, which has the desired effect of leaving
the sd_zbc_read_zones successfully with sdkp->zone_blocks = 0.
Fixes: 89d947561077 ("sd: Implement support for ZBC devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/scsi/sd_zbc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index 16d3fa62d8ac..d5b3bd915d9e 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -455,8 +455,10 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
/* Do a report zone to get the same field */
ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0);
- if (ret)
+ if (ret) {
+ zone_blocks = 0;
goto out;
+ }
same = buf[4] & 0x0f;
if (same > 0) {
--
2.9.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sd: fix uninitialized variable access in error handling
2016-10-21 15:32 [PATCH] sd: fix uninitialized variable access in error handling Arnd Bergmann
@ 2016-10-21 20:48 ` Shaun Tancheff
2016-10-23 23:37 ` Damien Le Moal
2016-10-24 14:37 ` Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Shaun Tancheff @ 2016-10-21 20:48 UTC (permalink / raw)
To: Arnd Bergmann
Cc: James E.J. Bottomley, Martin K. Petersen, Hannes Reinecke,
Jens Axboe, Damien Le Moal, linux-scsi, LKML
On Fri, Oct 21, 2016 at 10:32 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> If sd_zbc_report_zones fails, the check for 'zone_blocks == 0'
> later in the function accesses uninitialized data:
>
> drivers/scsi/sd_zbc.c: In function ‘sd_zbc_read_zones’:
> drivers/scsi/sd_zbc.c:520:7: error: ‘zone_blocks’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This sets it to zero, which has the desired effect of leaving
> the sd_zbc_read_zones successfully with sdkp->zone_blocks = 0.
>
> Fixes: 89d947561077 ("sd: Implement support for ZBC devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/scsi/sd_zbc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 16d3fa62d8ac..d5b3bd915d9e 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -455,8 +455,10 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
>
> /* Do a report zone to get the same field */
> ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0);
> - if (ret)
> + if (ret) {
> + zone_blocks = 0;
> goto out;
> + }
>
> same = buf[4] & 0x0f;
> if (same > 0) {
> --
> 2.9.0
>
Reviewed-by: Shaun Tancheff <shaun.tancheff@seagate.com>
--
Shaun Tancheff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sd: fix uninitialized variable access in error handling
2016-10-21 15:32 [PATCH] sd: fix uninitialized variable access in error handling Arnd Bergmann
2016-10-21 20:48 ` Shaun Tancheff
@ 2016-10-23 23:37 ` Damien Le Moal
2016-10-24 14:37 ` Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2016-10-23 23:37 UTC (permalink / raw)
To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen
Cc: Hannes Reinecke, Shaun Tancheff, Jens Axboe, Damien Le Moal,
linux-scsi, linux-kernel
On 10/22/16 00:32, Arnd Bergmann wrote:
> If sd_zbc_report_zones fails, the check for 'zone_blocks == 0'
> later in the function accesses uninitialized data:
>
> drivers/scsi/sd_zbc.c: In function ‘sd_zbc_read_zones’:
> drivers/scsi/sd_zbc.c:520:7: error: ‘zone_blocks’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This sets it to zero, which has the desired effect of leaving
> the sd_zbc_read_zones successfully with sdkp->zone_blocks = 0.
>
> Fixes: 89d947561077 ("sd: Implement support for ZBC devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/scsi/sd_zbc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 16d3fa62d8ac..d5b3bd915d9e 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -455,8 +455,10 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
>
> /* Do a report zone to get the same field */
> ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0);
> - if (ret)
> + if (ret) {
> + zone_blocks = 0;
> goto out;
> + }
>
> same = buf[4] & 0x0f;
> if (same > 0) {
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
--
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital Corporation
Damien.LeMoal@wdc.com
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sd: fix uninitialized variable access in error handling
2016-10-21 15:32 [PATCH] sd: fix uninitialized variable access in error handling Arnd Bergmann
2016-10-21 20:48 ` Shaun Tancheff
2016-10-23 23:37 ` Damien Le Moal
@ 2016-10-24 14:37 ` Hannes Reinecke
2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2016-10-24 14:37 UTC (permalink / raw)
To: Arnd Bergmann, James E.J. Bottomley, Martin K. Petersen
Cc: Shaun Tancheff, Jens Axboe, Damien Le Moal, linux-scsi, linux-kernel
On 10/21/2016 05:32 PM, Arnd Bergmann wrote:
> If sd_zbc_report_zones fails, the check for 'zone_blocks == 0'
> later in the function accesses uninitialized data:
>
> drivers/scsi/sd_zbc.c: In function ‘sd_zbc_read_zones’:
> drivers/scsi/sd_zbc.c:520:7: error: ‘zone_blocks’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
>
> This sets it to zero, which has the desired effect of leaving
> the sd_zbc_read_zones successfully with sdkp->zone_blocks = 0.
>
> Fixes: 89d947561077 ("sd: Implement support for ZBC devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/scsi/sd_zbc.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 16d3fa62d8ac..d5b3bd915d9e 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
> @@ -455,8 +455,10 @@ static int sd_zbc_check_zone_size(struct scsi_disk *sdkp)
>
> /* Do a report zone to get the same field */
> ret = sd_zbc_report_zones(sdkp, buf, SD_ZBC_BUF_SIZE, 0);
> - if (ret)
> + if (ret) {
> + zone_blocks = 0;
> goto out;
> + }
>
> same = buf[4] & 0x0f;
> if (same > 0) {
>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Cheers,
Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
hare@suse.de +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-10-24 14:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-21 15:32 [PATCH] sd: fix uninitialized variable access in error handling Arnd Bergmann
2016-10-21 20:48 ` Shaun Tancheff
2016-10-23 23:37 ` Damien Le Moal
2016-10-24 14:37 ` Hannes Reinecke
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).