Message ID | e028feca-f049-c3e5-ac4c-ec071a4e2972@omp.ru |
---|---|
State | New |
Headers | show |
Series | ata: libata-core: fix parameter type in ata_xfer_mode2shift() | expand |
On 4/10/22 04:13, Sergey Shtylyov wrote: > The data transfer mode that corresponds to the 'xfer_mode' parameter for > ata_xfer_mode2shift() is a 8-bit *unsigned* value. Using *unsigned long* > to declare the parameter leads to a problematic implicit *int* to *unsigned > long* cast and was most probably a result of a copy/paste mistake -- use > the 'u8' type instead, as in ata_xfer_mode2mask()... > > Found by Linux Verification Center (linuxtesting.org) with the SVACE static > analysis tool. > > Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> Applied to for-5.19. Thanks !
Index: libata/drivers/ata/libata-core.c =================================================================== --- libata.orig/drivers/ata/libata-core.c +++ libata/drivers/ata/libata-core.c @@ -898,7 +898,7 @@ EXPORT_SYMBOL_GPL(ata_xfer_mode2mask); * RETURNS: * Matching xfer_shift, -1 if no match found. */ -int ata_xfer_mode2shift(unsigned long xfer_mode) +int ata_xfer_mode2shift(u8 xfer_mode) { const struct ata_xfer_ent *ent; Index: libata/include/linux/libata.h =================================================================== --- libata.orig/include/linux/libata.h +++ libata/include/linux/libata.h @@ -1111,7 +1111,7 @@ extern void ata_unpack_xfermask(unsigned unsigned long *udma_mask); extern u8 ata_xfer_mask2mode(unsigned long xfer_mask); extern unsigned long ata_xfer_mode2mask(u8 xfer_mode); -extern int ata_xfer_mode2shift(unsigned long xfer_mode); +extern int ata_xfer_mode2shift(u8 xfer_mode); extern const char *ata_mode_string(unsigned long xfer_mask); extern unsigned long ata_id_xfermask(const u16 *id); extern int ata_std_qc_defer(struct ata_queued_cmd *qc);
The data transfer mode that corresponds to the 'xfer_mode' parameter for ata_xfer_mode2shift() is a 8-bit *unsigned* value. Using *unsigned long* to declare the parameter leads to a problematic implicit *int* to *unsigned long* cast and was most probably a result of a copy/paste mistake -- use the 'u8' type instead, as in ata_xfer_mode2mask()... Found by Linux Verification Center (linuxtesting.org) with the SVACE static analysis tool. Signed-off-by: Sergey Shtylyov <s.shtylyov@omp.ru> --- This patch is against the 'for-next' branch of Damien Le Moal's 'libata.git' repo. drivers/ata/libata-core.c | 2 +- include/linux/libata.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)