git: 7293d8210412 - stable/13 - mmc_da: fix garbage in disk->d_attachment
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 06 Aug 2025 06:04:54 UTC
The branch stable/13 has been updated by avg:
URL: https://cgit.FreeBSD.org/src/commit/?id=7293d821041206d0c520e798d3faa2a0639dea29
commit 7293d821041206d0c520e798d3faa2a0639dea29
Author: Andriy Gapon <avg@FreeBSD.org>
AuthorDate: 2025-06-23 21:43:35 +0000
Commit: Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2025-08-06 06:04:27 +0000
mmc_da: fix garbage in disk->d_attachment
The garbage resulted from reading the value from a ccb which was
originally populated by XPT_PATH_INQ operation but then overwritten by
XPT_GET_TRAN_SETTINGS operation.
The problem could probably be fixed by re-ordering the
XPT_GET_TRAN_SETTINGS operation, but it seems like the operation was
redundant. Besides, the ccb is declared not as union ccb but as struct
ccb_pathinq, so using it for XPT_GET_TRAN_SETTINGS was questionable.
I opted for replacing a call to sdda_get_max_data (which uses
XPT_GET_TRAN_SETTINGS internally) with using maxio provided by the
XPT_PATH_INQ operation.
This also required fixing mmc_cam_sim_default_action as controllers
return maximum I/O size in sectors, but maxio value should be in bytes.
(cherry picked from commit 5aedb8b1d4a6c099eaa0a65f8fcbdcc4aba8f75b)
---
sys/cam/mmc/mmc_da.c | 4 +---
sys/cam/mmc/mmc_sim.c | 2 +-
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/sys/cam/mmc/mmc_da.c b/sys/cam/mmc/mmc_da.c
index 81cbccb62693..6ea05863d646 100644
--- a/sys/cam/mmc/mmc_da.c
+++ b/sys/cam/mmc/mmc_da.c
@@ -1573,9 +1573,7 @@ sdda_add_part(struct cam_periph *periph, u_int type, const char *name,
part->disk->d_gone = sddadiskgonecb;
part->disk->d_name = part->name;
part->disk->d_drv1 = part;
- part->disk->d_maxsize =
- MIN(maxphys, sdda_get_max_data(periph,
- (union ccb *)&cpi) * mmc_get_sector_size(periph));
+ part->disk->d_maxsize = MIN(maxphys, cpi.maxio);
part->disk->d_unit = cnt;
part->disk->d_flags = 0;
strlcpy(part->disk->d_descr, sc->card_id_string,
diff --git a/sys/cam/mmc/mmc_sim.c b/sys/cam/mmc/mmc_sim.c
index 434cd6c65e64..809e682fc061 100644
--- a/sys/cam/mmc/mmc_sim.c
+++ b/sys/cam/mmc/mmc_sim.c
@@ -110,7 +110,7 @@ mmc_cam_sim_default_action(struct cam_sim *sim, union ccb *ccb)
ccb->ccb_h.status = CAM_REQ_INVALID;
} else {
mmc_path_inq(&ccb->cpi, "Deglitch Networks",
- sim, mmc.host_max_data);
+ sim, mmc.host_max_data * MMC_SECTOR_SIZE);
}
break;
case XPT_GET_TRAN_SETTINGS: