Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1537596 > unrolled thread

[PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled

Started byZhouyi Zhou <zhouzhouyi@gmail.com>
First post2016-12-07 09:10 +0100
Last post2016-12-07 09:40 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled Zhouyi Zhou <zhouzhouyi@gmail.com> - 2016-12-07 09:10 +0100
    Re: [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be  handled Johannes Thumshirn <jthumshirn@suse.de> - 2016-12-07 09:30 +0100
      Re: [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled Zhouyi Zhou <zhouzhouyi@gmail.com> - 2016-12-07 09:40 +0100

#1537596 — [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled

FromZhouyi Zhou <zhouzhouyi@gmail.com>
Date2016-12-07 09:10 +0100
Subject[PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled
Message-ID<sLFsC-5Xj-9@gated-at.bofh.it>
Return value of skb_linearize should be handled.

Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com> 
---
 drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 6 ++++--
 drivers/scsi/fcoe/fcoe.c          | 5 ++++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
index f9ddb61..142f7e2 100644
--- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
+++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
@@ -542,8 +542,10 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
 		return;
 	}
 
-	if (skb_is_nonlinear(skb))
-		skb_linearize(skb);
+	if (skb_linearize(skb)) {
+		kfree_skb(skb);
+		return;
+	}
 	mac = eth_hdr(skb)->h_source;
 	dest_mac = eth_hdr(skb)->h_dest;
 
diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 9bd41a3..4e3499c 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1685,7 +1685,10 @@ static void fcoe_recv_frame(struct sk_buff *skb)
 			skb->dev ? skb->dev->name : "<NULL>");
 
 	port = lport_priv(lport);
-	skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
+	if (skb_linearize(skb)) {
+		kfree_skb(skb);
+		return;
+	}
 
 	/*
 	 * Frame length checks and setting up the header pointers
-- 
1.9.1

[toc] | [next] | [standalone]


#1537601 — Re: [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled

FromJohannes Thumshirn <jthumshirn@suse.de>
Date2016-12-07 09:30 +0100
SubjectRe: [PATCH 1/1] scsi: fcoe: return value of skb_linearize should be handled
Message-ID<sLFLX-65b-3@gated-at.bofh.it>
In reply to#1537596
Hi Zhouyi,
On Wed, Dec 07, 2016 at 04:00:00PM +0800, Zhouyi Zhou wrote:
> Return value of skb_linearize should be handled.
> 
> Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com> 
> ---
>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 6 ++++--
>  drivers/scsi/fcoe/fcoe.c          | 5 ++++-
>  2 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> index f9ddb61..142f7e2 100644
> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
> @@ -542,8 +542,10 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
>  		return;
>  	}
>  
> -	if (skb_is_nonlinear(skb))
> -		skb_linearize(skb);
> +	if (skb_linearize(skb)) {
> +		kfree_skb(skb);
> +		return;
> +	}
>  	mac = eth_hdr(skb)->h_source;
>  	dest_mac = eth_hdr(skb)->h_dest;
>  
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index 9bd41a3..4e3499c 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -1685,7 +1685,10 @@ static void fcoe_recv_frame(struct sk_buff *skb)
>  			skb->dev ? skb->dev->name : "<NULL>");
>  
>  	port = lport_priv(lport);
> -	skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
> +	if (skb_linearize(skb)) {
> +		kfree_skb(skb);
> +		return;
> +	}
>  
>  	/*
>  	 * Frame length checks and setting up the header pointers
> -- 
> 1.9.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

I'd personally prefer something like:

diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
index 9bd41a3..bc6fa6c 100644
--- a/drivers/scsi/fcoe/fcoe.c
+++ b/drivers/scsi/fcoe/fcoe.c
@@ -1673,8 +1673,7 @@ static void fcoe_recv_frame(struct sk_buff *skb)
        lport = fr->fr_dev;
        if (unlikely(!lport)) {
                FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb\n");
-               kfree_skb(skb);
-               return;
+               goto free_skb;
        }
 
        FCOE_NETDEV_DBG(skb->dev,
@@ -1685,8 +1684,8 @@ static void fcoe_recv_frame(struct sk_buff *skb)
                        skb->dev ? skb->dev->name : "<NULL>");
 
        port = lport_priv(lport);
-       skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
-
+       if (skb_linearize(skb))
+               goto free_skb;
        /*
         * Frame length checks and setting up the header pointers
         * was done in fcoe_rcv already.
@@ -1732,6 +1731,7 @@ static void fcoe_recv_frame(struct sk_buff *skb)
 drop:
        stats->ErrorFrames++;
        put_cpu();
+free_skb:
        kfree_skb(skb);
 }


For bnx2fc as well if Chad agrees.

Thanks,
	Johannes

-- 
Johannes Thumshirn                                          Storage
jthumshirn@suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850

[toc] | [prev] | [next] | [standalone]


#1537605

FromZhouyi Zhou <zhouzhouyi@gmail.com>
Date2016-12-07 09:40 +0100
Message-ID<sLFVD-68d-5@gated-at.bofh.it>
In reply to#1537601
Thanks Johannes for reviewing, your code is indeeded more elegant

On Wed, Dec 7, 2016 at 4:28 PM, Johannes Thumshirn <jthumshirn@suse.de> wrote:
> Hi Zhouyi,
> On Wed, Dec 07, 2016 at 04:00:00PM +0800, Zhouyi Zhou wrote:
>> Return value of skb_linearize should be handled.
>>
>> Signed-off-by: Zhouyi Zhou <yizhouzhou@ict.ac.cn>
>> Reviewed-by: Yuval Shaia <yuval.shaia@oracle.com>
>> ---
>>  drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 6 ++++--
>>  drivers/scsi/fcoe/fcoe.c          | 5 ++++-
>>  2 files changed, 8 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> index f9ddb61..142f7e2 100644
>> --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c
>> @@ -542,8 +542,10 @@ static void bnx2fc_recv_frame(struct sk_buff *skb)
>>               return;
>>       }
>>
>> -     if (skb_is_nonlinear(skb))
>> -             skb_linearize(skb);
>> +     if (skb_linearize(skb)) {
>> +             kfree_skb(skb);
>> +             return;
>> +     }
>>       mac = eth_hdr(skb)->h_source;
>>       dest_mac = eth_hdr(skb)->h_dest;
>>
>> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
>> index 9bd41a3..4e3499c 100644
>> --- a/drivers/scsi/fcoe/fcoe.c
>> +++ b/drivers/scsi/fcoe/fcoe.c
>> @@ -1685,7 +1685,10 @@ static void fcoe_recv_frame(struct sk_buff *skb)
>>                       skb->dev ? skb->dev->name : "<NULL>");
>>
>>       port = lport_priv(lport);
>> -     skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
>> +     if (skb_linearize(skb)) {
>> +             kfree_skb(skb);
>> +             return;
>> +     }
>>
>>       /*
>>        * Frame length checks and setting up the header pointers
>> --
>> 1.9.1
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> I'd personally prefer something like:
>
> diff --git a/drivers/scsi/fcoe/fcoe.c b/drivers/scsi/fcoe/fcoe.c
> index 9bd41a3..bc6fa6c 100644
> --- a/drivers/scsi/fcoe/fcoe.c
> +++ b/drivers/scsi/fcoe/fcoe.c
> @@ -1673,8 +1673,7 @@ static void fcoe_recv_frame(struct sk_buff *skb)
>         lport = fr->fr_dev;
>         if (unlikely(!lport)) {
>                 FCOE_NETDEV_DBG(skb->dev, "NULL lport in skb\n");
> -               kfree_skb(skb);
> -               return;
> +               goto free_skb;
>         }
>
>         FCOE_NETDEV_DBG(skb->dev,
> @@ -1685,8 +1684,8 @@ static void fcoe_recv_frame(struct sk_buff *skb)
>                         skb->dev ? skb->dev->name : "<NULL>");
>
>         port = lport_priv(lport);
> -       skb_linearize(skb); /* check for skb_is_nonlinear is within skb_linearize */
> -
> +       if (skb_linearize(skb))
> +               goto free_skb;
>         /*
>          * Frame length checks and setting up the header pointers
>          * was done in fcoe_rcv already.
> @@ -1732,6 +1731,7 @@ static void fcoe_recv_frame(struct sk_buff *skb)
>  drop:
>         stats->ErrorFrames++;
>         put_cpu();
> +free_skb:
>         kfree_skb(skb);
>  }
>
>
> For bnx2fc as well if Chad agrees.
>
> Thanks,
>         Johannes
>
> --
> Johannes Thumshirn                                          Storage
> jthumshirn@suse.de                                +49 911 74053 689
> SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
> GF: Felix Imendörffer, Jane Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)
> Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850
Thanks
Zhouyi

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web