diff mbox

[1/3] IB/umad: Remove container_of() != NULL tests

Message ID 5370869F.5040103@acm.org (mailing list archive)
State Superseded, archived
Headers show

Commit Message

Bart Van Assche May 12, 2014, 8:30 a.m. UTC
container_of() never returns NULL. Hence remove the code that tests
whether container_of() returns NULL.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Cc: Alex Chiang <achiang@hp.com>
Cc: <stable@vger.kernel.org>
---
 drivers/infiniband/core/user_mad.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

Comments

Yann Droneaud May 12, 2014, 10:04 a.m. UTC | #1
Hi,

Le lundi 12 mai 2014 à 10:30 +0200, Bart Van Assche a écrit :
> container_of() never returns NULL. Hence remove the code that tests
> whether container_of() returns NULL.
> 
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> Cc: Alex Chiang <achiang@hp.com>
> Cc: <stable@vger.kernel.org>

The patch seems fine.

But I don't think this one qualify for linux-stable.

> ---
>  drivers/infiniband/core/user_mad.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
> index f0d588f..e61287c 100644
> --- a/drivers/infiniband/core/user_mad.c
> +++ b/drivers/infiniband/core/user_mad.c
> @@ -783,10 +783,7 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
>  	int ret;
>  
>  	port = container_of(inode->i_cdev, struct ib_umad_port, cdev);
> -	if (port)
> -		kref_get(&port->umad_dev->ref);
> -	else
> -		return -ENXIO;
> +	kref_get(&port->umad_dev->ref);
>  
>  	mutex_lock(&port->file_mutex);
>  
> @@ -880,10 +877,7 @@ static int ib_umad_sm_open(struct inode *inode, struct file *filp)
>  	int ret;
>  
>  	port = container_of(inode->i_cdev, struct ib_umad_port, sm_cdev);
> -	if (port)
> -		kref_get(&port->umad_dev->ref);
> -	else
> -		return -ENXIO;
> +	kref_get(&port->umad_dev->ref);
>  
>  	if (filp->f_flags & O_NONBLOCK) {
>  		if (down_trylock(&port->sm_sem)) {

Regards.
Bart Van Assche May 12, 2014, 10:36 a.m. UTC | #2
On 05/12/14 12:04, Yann Droneaud wrote:
> Le lundi 12 mai 2014 à 10:30 +0200, Bart Van Assche a écrit :
>> container_of() never returns NULL. Hence remove the code that tests
>> whether container_of() returns NULL.
>>
>> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
>> Cc: Alex Chiang <achiang@hp.com>
>> Cc: <stable@vger.kernel.org>
> The patch seems fine.
>
> But I don't think this one qualify for linux-stable.

One chunk in patch 3/3 touches code that is also touched by this patch.
This means that if only patches 2/3 and 3/3 would be sent to stable that
these wouldn't apply properly. Hence the "Cc: stable" tag in this patch.

Bart.

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Yann Droneaud May 12, 2014, 12:40 p.m. UTC | #3
Le lundi 12 mai 2014 à 12:36 +0200, Bart Van Assche a écrit :
> On 05/12/14 12:04, Yann Droneaud wrote:
> > Le lundi 12 mai 2014 à 10:30 +0200, Bart Van Assche a écrit :
> >> container_of() never returns NULL. Hence remove the code that tests
> >> whether container_of() returns NULL.
> >>
> >> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> >> Cc: Alex Chiang <achiang@hp.com>
> >> Cc: <stable@vger.kernel.org>
> > The patch seems fine.
> >
> > But I don't think this one qualify for linux-stable.
> 
> One chunk in patch 3/3 touches code that is also touched by this patch.
> This means that if only patches 2/3 and 3/3 would be sent to stable that
> these wouldn't apply properly. Hence the "Cc: stable" tag in this patch.
> 

You could re-order the patches to make this one apply on top of the two
others.

Anyway, it's a minor issue that doesn't justifiy by itself to respin the
patchset. But if you're going to take account of my others remarks, it
might be worth to reorder the patchset.

Regards.
diff mbox

Patch

diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index f0d588f..e61287c 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -783,10 +783,7 @@  static int ib_umad_open(struct inode *inode, struct file *filp)
 	int ret;
 
 	port = container_of(inode->i_cdev, struct ib_umad_port, cdev);
-	if (port)
-		kref_get(&port->umad_dev->ref);
-	else
-		return -ENXIO;
+	kref_get(&port->umad_dev->ref);
 
 	mutex_lock(&port->file_mutex);
 
@@ -880,10 +877,7 @@  static int ib_umad_sm_open(struct inode *inode, struct file *filp)
 	int ret;
 
 	port = container_of(inode->i_cdev, struct ib_umad_port, sm_cdev);
-	if (port)
-		kref_get(&port->umad_dev->ref);
-	else
-		return -ENXIO;
+	kref_get(&port->umad_dev->ref);
 
 	if (filp->f_flags & O_NONBLOCK) {
 		if (down_trylock(&port->sm_sem)) {