Skip to content

Commit fd6c10c

Browse files
committed
Merge branch 'remotes/lorenzo/pci/endpoint'
- Use sysfs_emit() in "show" functions instead of sprintf() to avoid buffer overruns (Kunihiko Hayashi) * remotes/lorenzo/pci/endpoint: PCI: endpoint: Use sysfs_emit() in "show" functions
2 parents 07dd8bb + a225883 commit fd6c10c

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

drivers/pci/endpoint/functions/pci-epf-ntb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
19371937
struct config_group *group = to_config_group(item); \
19381938
struct epf_ntb *ntb = to_epf_ntb(group); \
19391939
\
1940-
return sprintf(page, "%d\n", ntb->_name); \
1940+
return sysfs_emit(page, "%d\n", ntb->_name); \
19411941
}
19421942

19431943
#define EPF_NTB_W(_name) \
@@ -1966,7 +1966,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
19661966
\
19671967
sscanf(#_name, "mw%d", &win_no); \
19681968
\
1969-
return sprintf(page, "%lld\n", ntb->mws_size[win_no - 1]); \
1969+
return sysfs_emit(page, "%lld\n", ntb->mws_size[win_no - 1]); \
19701970
}
19711971

19721972
#define EPF_NTB_MW_W(_name) \

drivers/pci/endpoint/pci-ep-cfs.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,7 @@ static ssize_t pci_epc_start_store(struct config_item *item, const char *page,
197197

198198
static ssize_t pci_epc_start_show(struct config_item *item, char *page)
199199
{
200-
return sprintf(page, "%d\n",
201-
to_pci_epc_group(item)->start);
200+
return sysfs_emit(page, "%d\n", to_pci_epc_group(item)->start);
202201
}
203202

204203
CONFIGFS_ATTR(pci_epc_, start);
@@ -320,7 +319,7 @@ static ssize_t pci_epf_##_name##_show(struct config_item *item, char *page) \
320319
struct pci_epf *epf = to_pci_epf_group(item)->epf; \
321320
if (WARN_ON_ONCE(!epf->header)) \
322321
return -EINVAL; \
323-
return sprintf(page, "0x%04x\n", epf->header->_name); \
322+
return sysfs_emit(page, "0x%04x\n", epf->header->_name); \
324323
}
325324

326325
#define PCI_EPF_HEADER_W_u32(_name) \
@@ -381,8 +380,8 @@ static ssize_t pci_epf_msi_interrupts_store(struct config_item *item,
381380
static ssize_t pci_epf_msi_interrupts_show(struct config_item *item,
382381
char *page)
383382
{
384-
return sprintf(page, "%d\n",
385-
to_pci_epf_group(item)->epf->msi_interrupts);
383+
return sysfs_emit(page, "%d\n",
384+
to_pci_epf_group(item)->epf->msi_interrupts);
386385
}
387386

388387
static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
@@ -401,8 +400,8 @@ static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
401400
static ssize_t pci_epf_msix_interrupts_show(struct config_item *item,
402401
char *page)
403402
{
404-
return sprintf(page, "%d\n",
405-
to_pci_epf_group(item)->epf->msix_interrupts);
403+
return sysfs_emit(page, "%d\n",
404+
to_pci_epf_group(item)->epf->msix_interrupts);
406405
}
407406

408407
PCI_EPF_HEADER_R(vendorid)

0 commit comments

Comments
 (0)