Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1506277
| From | Shaun Tancheff <shaun.tancheff@seagate.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] sd: fix uninitialized variable access in error handling |
| Date | 2016-10-21 22:50 +0200 |
| Message-ID | <suOVj-2gP-5@gated-at.bofh.it> (permalink) |
| References | <suK5k-7xe-31@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] sd: fix uninitialized variable access in error handling Arnd Bergmann <arnd@arndb.de> - 2016-10-21 17:40 +0200 Re: [PATCH] sd: fix uninitialized variable access in error handling Shaun Tancheff <shaun.tancheff@seagate.com> - 2016-10-21 22:50 +0200 Re: [PATCH] sd: fix uninitialized variable access in error handling Hannes Reinecke <hare@suse.de> - 2016-10-24 16:40 +0200
csiph-web