Skip to content

Commit 9b980d9

Browse files
tchardingstorulf
authored andcommitted
mmc: core: guard dereference of optional parameter
Various functions take as parameter an optional pointer. Pointer should be guarded with non-NULL check before dereferencing. Add non-NULL check before dereference of pointer. Signed-off-by: Tobin C. Harding <me@tobin.cc> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ce473d5 commit 9b980d9

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/mmc/core/sdio_io.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ u8 sdio_readb(struct sdio_func *func, unsigned int addr, int *err_ret)
373373
u8 val;
374374

375375
if (!func) {
376-
*err_ret = -EINVAL;
376+
if (err_ret)
377+
*err_ret = -EINVAL;
377378
return 0xFF;
378379
}
379380

@@ -407,7 +408,8 @@ void sdio_writeb(struct sdio_func *func, u8 b, unsigned int addr, int *err_ret)
407408
int ret;
408409

409410
if (!func) {
410-
*err_ret = -EINVAL;
411+
if (err_ret)
412+
*err_ret = -EINVAL;
411413
return;
412414
}
413415

@@ -635,7 +637,8 @@ unsigned char sdio_f0_readb(struct sdio_func *func, unsigned int addr,
635637
unsigned char val;
636638

637639
if (!func) {
638-
*err_ret = -EINVAL;
640+
if (err_ret)
641+
*err_ret = -EINVAL;
639642
return 0xFF;
640643
}
641644

@@ -673,7 +676,8 @@ void sdio_f0_writeb(struct sdio_func *func, unsigned char b, unsigned int addr,
673676
int ret;
674677

675678
if (!func) {
676-
*err_ret = -EINVAL;
679+
if (err_ret)
680+
*err_ret = -EINVAL;
677681
return;
678682
}
679683

0 commit comments

Comments
 (0)