Index: sys/cam/mmc/mmc_da.c =================================================================== --- sys/cam/mmc/mmc_da.c +++ sys/cam/mmc/mmc_da.c @@ -204,7 +204,7 @@ static uint32_t mmc_get_spec_vers(struct cam_periph *periph); static uint64_t mmc_get_media_size(struct cam_periph *periph); static uint32_t mmc_get_cmd6_timeout(struct cam_periph *periph); -static void sdda_add_part(struct cam_periph *periph, u_int type, +static bool sdda_add_part(struct cam_periph *periph, u_int type, const char *name, u_int cnt, off_t media_size, bool ro); static struct periph_driver sddadriver = @@ -1510,10 +1510,11 @@ sdda_process_mmc_partitions(periph, start_ccb); } else if (mmcp->card_features & CARD_FEATURE_SD20) { /* For SD[HC] cards, just add one partition that is the whole card */ - sdda_add_part(periph, 0, "sdda", + if (sdda_add_part(periph, 0, "sdda", periph->unit_number, mmc_get_media_size(periph), - sdda_get_read_only(periph, start_ccb)); + sdda_get_read_only(periph, start_ccb)) == false) + return; softc->part_curr = 0; } @@ -1528,7 +1529,7 @@ AC_ADVINFO_CHANGED, sddaasync, periph, periph->path); } -static void +static bool sdda_add_part(struct cam_periph *periph, u_int type, const char *name, u_int cnt, off_t media_size, bool ro) { @@ -1543,7 +1544,11 @@ ro ? "(read-only)" : "")); part = sc->part[type] = malloc(sizeof(*part), M_DEVBUF, - M_WAITOK | M_ZERO); + M_NOWAIT | M_ZERO); + if (part == NULL) { + printf("Cannot add partition for sdda\n"); + return (false); + } part->cnt = cnt; part->type = type; @@ -1561,7 +1566,7 @@ /* TODO: Create device, assign IOCTL handler */ CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Don't know what to do with RPMB partitions yet\n")); - return; + return (false); } bioq_init(&part->bio_queue); @@ -1627,11 +1632,13 @@ xpt_print(periph->path, "%s: lost periph during " "registration!\n", __func__); cam_periph_lock(periph); - return; + return (false); } disk_create(part->disk, DISK_VERSION); cam_periph_lock(periph); cam_periph_unhold(periph); + + return (true); } /*