* [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs
@ 2017-06-28 12:00 Joerg Roedel
[not found] ` <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2017-06-28 12:00 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA,
Gerald Schaefer
From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
The generic device_group call-backs in iommu.c return NULL
in case of error. Since they are getting ERR_PTR values from
iommu_group_alloc(), just pass them up instead.
Reported-by: Gerald Schaefer <gerald.schaefer-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
---
drivers/iommu/iommu.c | 14 ++------------
1 file changed, 2 insertions(+), 12 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index cf7ca7e..de09e1e 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -915,13 +915,7 @@ static int get_pci_alias_or_group(struct pci_dev *pdev, u16 alias, void *opaque)
*/
struct iommu_group *generic_device_group(struct device *dev)
{
- struct iommu_group *group;
-
- group = iommu_group_alloc();
- if (IS_ERR(group))
- return NULL;
-
- return group;
+ return iommu_group_alloc();
}
/*
@@ -988,11 +982,7 @@ struct iommu_group *pci_device_group(struct device *dev)
return group;
/* No shared group found, allocate new */
- group = iommu_group_alloc();
- if (IS_ERR(group))
- return NULL;
-
- return group;
+ return iommu_group_alloc();
}
/**
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread[parent not found: <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* [PATCH 2/3] iommu/omap: Return ERR_PTR in device_group call-back [not found] ` <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-06-28 12:00 ` Joerg Roedel [not found] ` <1498651258-23700-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-06-28 12:00 ` [PATCH 3/3] iommu: Warn once when device_group callback returns NULL Joerg Roedel 2017-06-28 15:48 ` [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs Gerald Schaefer 2 siblings, 1 reply; 5+ messages in thread From: Joerg Roedel @ 2017-06-28 12:00 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Gerald Schaefer From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> Make sure that the device_group callback returns an ERR_PTR instead of NULL. Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/iommu/omap-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index 95dfca3..641e035 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c @@ -1309,7 +1309,7 @@ static void omap_iommu_remove_device(struct device *dev) static struct iommu_group *omap_iommu_device_group(struct device *dev) { struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; - struct iommu_group *group = NULL; + struct iommu_group *group = ERR_PTR(-EINVAL); if (arch_data->iommu_dev) group = arch_data->iommu_dev->group; -- 2.7.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
[parent not found: <1498651258-23700-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>]
* Re: [PATCH 2/3] iommu/omap: Return ERR_PTR in device_group call-back [not found] ` <1498651258-23700-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> @ 2017-06-28 16:32 ` Suman Anna via iommu 0 siblings, 0 replies; 5+ messages in thread From: Suman Anna via iommu @ 2017-06-28 16:32 UTC (permalink / raw) To: Joerg Roedel, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Gerald Schaefer On 06/28/2017 07:00 AM, Joerg Roedel wrote: > From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > > Make sure that the device_group callback returns an ERR_PTR > instead of NULL. > > Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> Thanks for the patch, Acked-by: Suman Anna <s-anna-l0cyMroinI0@public.gmane.org> regards Suman > --- > drivers/iommu/omap-iommu.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c > index 95dfca3..641e035 100644 > --- a/drivers/iommu/omap-iommu.c > +++ b/drivers/iommu/omap-iommu.c > @@ -1309,7 +1309,7 @@ static void omap_iommu_remove_device(struct device *dev) > static struct iommu_group *omap_iommu_device_group(struct device *dev) > { > struct omap_iommu_arch_data *arch_data = dev->archdata.iommu; > - struct iommu_group *group = NULL; > + struct iommu_group *group = ERR_PTR(-EINVAL); > > if (arch_data->iommu_dev) > group = arch_data->iommu_dev->group; > ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 3/3] iommu: Warn once when device_group callback returns NULL [not found] ` <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-06-28 12:00 ` [PATCH 2/3] iommu/omap: Return ERR_PTR in device_group call-back Joerg Roedel @ 2017-06-28 12:00 ` Joerg Roedel 2017-06-28 15:48 ` [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs Gerald Schaefer 2 siblings, 0 replies; 5+ messages in thread From: Joerg Roedel @ 2017-06-28 12:00 UTC (permalink / raw) To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA Cc: Joerg Roedel, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Gerald Schaefer From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> This callback should never return NULL. Print a warning if that happens so that we notice and can fix it. Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> --- drivers/iommu/iommu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index de09e1e..3f6ea16 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1010,6 +1010,9 @@ struct iommu_group *iommu_group_get_for_dev(struct device *dev) if (ops && ops->device_group) group = ops->device_group(dev); + if (WARN_ON_ONCE(group == NULL)) + return ERR_PTR(-EINVAL); + if (IS_ERR(group)) return group; -- 2.7.4 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs [not found] ` <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> 2017-06-28 12:00 ` [PATCH 2/3] iommu/omap: Return ERR_PTR in device_group call-back Joerg Roedel 2017-06-28 12:00 ` [PATCH 3/3] iommu: Warn once when device_group callback returns NULL Joerg Roedel @ 2017-06-28 15:48 ` Gerald Schaefer 2 siblings, 0 replies; 5+ messages in thread From: Gerald Schaefer @ 2017-06-28 15:48 UTC (permalink / raw) To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA, linux-kernel-u79uwXL29TY76Z2rM5mHXA, Joerg Roedel On Wed, 28 Jun 2017 14:00:56 +0200 Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> wrote: > From: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > > The generic device_group call-backs in iommu.c return NULL > in case of error. Since they are getting ERR_PTR values from > iommu_group_alloc(), just pass them up instead. > > Reported-by: Gerald Schaefer <gerald.schaefer-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org> > Signed-off-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org> > --- Looks good, Reviewed-by: Gerald Schaefer <gerald.schaefer-tA70FqPdS9bQT0dZR+AlfA@public.gmane.org> > drivers/iommu/iommu.c | 14 ++------------ > 1 file changed, 2 insertions(+), 12 deletions(-) > > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > index cf7ca7e..de09e1e 100644 > --- a/drivers/iommu/iommu.c > +++ b/drivers/iommu/iommu.c > @@ -915,13 +915,7 @@ static int get_pci_alias_or_group(struct pci_dev *pdev, u16 alias, void *opaque) > */ > struct iommu_group *generic_device_group(struct device *dev) > { > - struct iommu_group *group; > - > - group = iommu_group_alloc(); > - if (IS_ERR(group)) > - return NULL; > - > - return group; > + return iommu_group_alloc(); > } > > /* > @@ -988,11 +982,7 @@ struct iommu_group *pci_device_group(struct device *dev) > return group; > > /* No shared group found, allocate new */ > - group = iommu_group_alloc(); > - if (IS_ERR(group)) > - return NULL; > - > - return group; > + return iommu_group_alloc(); > } > > /** ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-06-28 16:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-28 12:00 [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs Joerg Roedel
[not found] ` <1498651258-23700-1-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-06-28 12:00 ` [PATCH 2/3] iommu/omap: Return ERR_PTR in device_group call-back Joerg Roedel
[not found] ` <1498651258-23700-2-git-send-email-joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
2017-06-28 16:32 ` Suman Anna via iommu
2017-06-28 12:00 ` [PATCH 3/3] iommu: Warn once when device_group callback returns NULL Joerg Roedel
2017-06-28 15:48 ` [PATCH 1/3] iommu: Return ERR_PTR() values from device_group call-backs Gerald Schaefer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox