diff options
author | Toomas Soome <tsoome@FreeBSD.org> | 2017-02-08 18:32:53 +0000 |
---|---|---|
committer | Toomas Soome <tsoome@FreeBSD.org> | 2017-02-08 18:32:53 +0000 |
commit | 6db947347cbd52ae50a94b1f11fb8758dfd3afa4 (patch) | |
tree | 808e0697687b68b69061a46367745f7452bea108 /sys/boot | |
parent | 3ff519254c7d847ddbfb0a73b761d3f1b0ba0e9d (diff) | |
download | src-6db947347cbd52ae50a94b1f11fb8758dfd3afa4.tar.gz src-6db947347cbd52ae50a94b1f11fb8758dfd3afa4.zip |
loader: possible NULL pointer dereference in bcache.c
Coverity detected the possible NULL pointer dereference case.
Also updated comment as was suggested in illumos review.
CID: 1371008
Reported by: Coverity
Reviewed by: allanjude
Approved by: allanjude (mentor)
Differential Revision: https://reviews.freebsd.org/D9496
Notes
Notes:
svn path=/head/; revision=313451
Diffstat (limited to 'sys/boot')
-rw-r--r-- | sys/boot/common/bcache.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sys/boot/common/bcache.c b/sys/boot/common/bcache.c index 787d78a600bf..3c1ee64792ad 100644 --- a/sys/boot/common/bcache.c +++ b/sys/boot/common/bcache.c @@ -224,13 +224,13 @@ read_strategy(void *devdata, int rw, daddr_t blk, size_t size, caddr_t p_buf; uint32_t *marker; - marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); - if (bc == NULL) { errno = ENODEV; return (-1); } + marker = (uint32_t *)(bc->bcache_data + bc->bcache_nblks * bcache_blksize); + if (rsize != NULL) *rsize = 0; @@ -290,10 +290,9 @@ read_strategy(void *devdata, int rw, daddr_t blk, size_t size, * And secondly, this way we get the most conservative setup for the ra. * * The selection of multiple of 16 blocks (8KB) is quite arbitrary, however, - * we want to have the CD (2K) and the 4K disks to be covered. - * Also, as we have 32 blocks to be allocated as the fallback value in the - * bcache_allocate(), the 16 ra blocks will allow the read ahead - * to be used even with bcache this small. + * we want to cover CDs (2K) and 4K disks. + * bcache_allocate() will always fall back to a minimum of 32 blocks. + * Our choice of 16 read ahead blocks will always fit inside the bcache. */ ra = bc->bcache_nblks - BHASH(bc, p_blk + p_size); |