subsys: disk: Fix NULL pointer checks for disk operations

Fix NULL pointerer checks for disk supported operatins.

CID: 186027
CID: 186029
CID: 186045
CID: 186056
CID: 186063

Fixes Issues #7742 #7740 #7726 #7718 #7712

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
This commit is contained in:
Ramakrishna Pallala 2018-05-23 10:08:05 +05:30 committed by Anas Nashif
commit 2f074783c4

View file

@ -57,7 +57,7 @@ int disk_access_init(const char *pdrv)
struct disk_info *disk = disk_access_get_di(pdrv);
int rc = -EINVAL;
if ((disk != NULL) || (disk->ops != NULL) ||
if ((disk != NULL) && (disk->ops != NULL) &&
(disk->ops->init != NULL)) {
rc = disk->ops->init(disk);
}
@ -70,7 +70,7 @@ int disk_access_status(const char *pdrv)
struct disk_info *disk = disk_access_get_di(pdrv);
int rc = -EINVAL;
if ((disk != NULL) || (disk->ops != NULL) ||
if ((disk != NULL) && (disk->ops != NULL) &&
(disk->ops->status != NULL)) {
rc = disk->ops->status(disk);
}
@ -84,7 +84,7 @@ int disk_access_read(const char *pdrv, u8_t *data_buf,
struct disk_info *disk = disk_access_get_di(pdrv);
int rc = -EINVAL;
if ((disk != NULL) || (disk->ops != NULL) ||
if ((disk != NULL) && (disk->ops != NULL) &&
(disk->ops->read != NULL)) {
rc = disk->ops->read(disk, data_buf, start_sector, num_sector);
}
@ -98,7 +98,7 @@ int disk_access_write(const char *pdrv, const u8_t *data_buf,
struct disk_info *disk = disk_access_get_di(pdrv);
int rc = -EINVAL;
if ((disk != NULL) || (disk->ops != NULL) ||
if ((disk != NULL) && (disk->ops != NULL) &&
(disk->ops->write != NULL)) {
rc = disk->ops->write(disk, data_buf, start_sector, num_sector);
}
@ -111,7 +111,7 @@ int disk_access_ioctl(const char *pdrv, u8_t cmd, void *buf)
struct disk_info *disk = disk_access_get_di(pdrv);
int rc = -EINVAL;
if ((disk != NULL) || (disk->ops != NULL) ||
if ((disk != NULL) && (disk->ops != NULL) &&
(disk->ops->ioctl != NULL)) {
rc = disk->ops->ioctl(disk, cmd, buf);
}