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
This commit is contained in:
commit
fd6c10ca26
@ -1937,7 +1937,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
|
|||||||
struct config_group *group = to_config_group(item); \
|
struct config_group *group = to_config_group(item); \
|
||||||
struct epf_ntb *ntb = to_epf_ntb(group); \
|
struct epf_ntb *ntb = to_epf_ntb(group); \
|
||||||
\
|
\
|
||||||
return sprintf(page, "%d\n", ntb->_name); \
|
return sysfs_emit(page, "%d\n", ntb->_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EPF_NTB_W(_name) \
|
#define EPF_NTB_W(_name) \
|
||||||
@ -1966,7 +1966,7 @@ static ssize_t epf_ntb_##_name##_show(struct config_item *item, \
|
|||||||
\
|
\
|
||||||
sscanf(#_name, "mw%d", &win_no); \
|
sscanf(#_name, "mw%d", &win_no); \
|
||||||
\
|
\
|
||||||
return sprintf(page, "%lld\n", ntb->mws_size[win_no - 1]); \
|
return sysfs_emit(page, "%lld\n", ntb->mws_size[win_no - 1]); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define EPF_NTB_MW_W(_name) \
|
#define EPF_NTB_MW_W(_name) \
|
||||||
|
@ -197,8 +197,7 @@ static ssize_t pci_epc_start_store(struct config_item *item, const char *page,
|
|||||||
|
|
||||||
static ssize_t pci_epc_start_show(struct config_item *item, char *page)
|
static ssize_t pci_epc_start_show(struct config_item *item, char *page)
|
||||||
{
|
{
|
||||||
return sprintf(page, "%d\n",
|
return sysfs_emit(page, "%d\n", to_pci_epc_group(item)->start);
|
||||||
to_pci_epc_group(item)->start);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR(pci_epc_, start);
|
CONFIGFS_ATTR(pci_epc_, start);
|
||||||
@ -320,7 +319,7 @@ static ssize_t pci_epf_##_name##_show(struct config_item *item, char *page) \
|
|||||||
struct pci_epf *epf = to_pci_epf_group(item)->epf; \
|
struct pci_epf *epf = to_pci_epf_group(item)->epf; \
|
||||||
if (WARN_ON_ONCE(!epf->header)) \
|
if (WARN_ON_ONCE(!epf->header)) \
|
||||||
return -EINVAL; \
|
return -EINVAL; \
|
||||||
return sprintf(page, "0x%04x\n", epf->header->_name); \
|
return sysfs_emit(page, "0x%04x\n", epf->header->_name); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PCI_EPF_HEADER_W_u32(_name) \
|
#define PCI_EPF_HEADER_W_u32(_name) \
|
||||||
@ -381,8 +380,8 @@ static ssize_t pci_epf_msi_interrupts_store(struct config_item *item,
|
|||||||
static ssize_t pci_epf_msi_interrupts_show(struct config_item *item,
|
static ssize_t pci_epf_msi_interrupts_show(struct config_item *item,
|
||||||
char *page)
|
char *page)
|
||||||
{
|
{
|
||||||
return sprintf(page, "%d\n",
|
return sysfs_emit(page, "%d\n",
|
||||||
to_pci_epf_group(item)->epf->msi_interrupts);
|
to_pci_epf_group(item)->epf->msi_interrupts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static ssize_t pci_epf_msix_interrupts_store(struct config_item *item,
|
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,
|
|||||||
static ssize_t pci_epf_msix_interrupts_show(struct config_item *item,
|
static ssize_t pci_epf_msix_interrupts_show(struct config_item *item,
|
||||||
char *page)
|
char *page)
|
||||||
{
|
{
|
||||||
return sprintf(page, "%d\n",
|
return sysfs_emit(page, "%d\n",
|
||||||
to_pci_epf_group(item)->epf->msix_interrupts);
|
to_pci_epf_group(item)->epf->msix_interrupts);
|
||||||
}
|
}
|
||||||
|
|
||||||
PCI_EPF_HEADER_R(vendorid)
|
PCI_EPF_HEADER_R(vendorid)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user