Module Name: src Committed By: bouyer Date: Wed Feb 7 14:42:07 UTC 2018
Modified Files: src/sys/dev/sdmmc: sdmmc_mem.c Log Message: Fix uninitialized variable use: if there is an error, or if we are using a SPI controller, sdmmc_mem_send_op_cond() doens't assign a value to *ocrp, but it is used unconditionally in sdmmc_mem_enable() to see if we can switch to low voltage. In sdmmc_mem_send_op_cond(), if the new ocr is not returned by the card for whatever reason, set *ocrp to the orig value. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/sys/dev/sdmmc/sdmmc_mem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/sdmmc/sdmmc_mem.c diff -u src/sys/dev/sdmmc/sdmmc_mem.c:1.63 src/sys/dev/sdmmc/sdmmc_mem.c:1.64 --- src/sys/dev/sdmmc/sdmmc_mem.c:1.63 Tue Sep 12 13:43:37 2017 +++ src/sys/dev/sdmmc/sdmmc_mem.c Wed Feb 7 14:42:07 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: sdmmc_mem.c,v 1.63 2017/09/12 13:43:37 jmcneill Exp $ */ +/* $NetBSD: sdmmc_mem.c,v 1.64 2018/02/07 14:42:07 bouyer Exp $ */ /* $OpenBSD: sdmmc_mem.c,v 1.10 2009/01/09 10:55:22 jsg Exp $ */ /* @@ -45,7 +45,7 @@ /* Routines for SD/MMC memory cards. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.63 2017/09/12 13:43:37 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sdmmc_mem.c,v 1.64 2018/02/07 14:42:07 bouyer Exp $"); #ifdef _KERNEL_OPT #include "opt_sdmmc.h" @@ -644,10 +644,14 @@ sdmmc_mem_send_op_cond(struct sdmmc_soft error = ETIMEDOUT; sdmmc_delay(10000); } - if (error == 0 && - ocrp != NULL && - !ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) - *ocrp = MMC_R3(cmd.c_resp); + if (ocrp != NULL) { + if (error == 0 && + !ISSET(sc->sc_caps, SMC_CAPS_SPI_MODE)) { + *ocrp = MMC_R3(cmd.c_resp); + } else { + *ocrp = ocr; + } + } DPRINTF(("%s: sdmmc_mem_send_op_cond: error=%d, ocr=%#x\n", SDMMCDEVNAME(sc), error, MMC_R3(cmd.c_resp))); return error;