diff mbox

NFC: microread: use kfree_skb() instead of kfree()

Message ID CAPgLHd-BKoizHok9hDdAz9yBY1YqfpTov6s3CoefPTtbacQW3g@mail.gmail.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Wei Yongjun March 21, 2013, 7:40 a.m. UTC
From: Wei Yongjun <yongjun_wei@trendmicro.com.cn>

Use kfree_skb() instead of kfree() to free sk_buff.

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
---
 drivers/nfc/microread/mei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Waldemar Rymarkiewicz March 21, 2013, 11:37 a.m. UTC | #1
Hi,

> Use kfree_skb() instead of kfree() to free sk_buff.
>
> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
> ---
>   drivers/nfc/microread/mei.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c
> index eef38cf..da8264c 100644
> --- a/drivers/nfc/microread/mei.c
> +++ b/drivers/nfc/microread/mei.c
> @@ -130,7 +130,7 @@ static void microread_event_cb(struct mei_device *device, u32 events,
>
>   		reply_size = mei_recv(device, skb->data, MEI_NFC_MAX_READ);
>   		if (reply_size < MEI_NFC_HEADER_SIZE) {
> -			kfree(skb);
> +			kfree_skb(skb);
>   			return;
>   		}

kfree_skb call is used internally by the kernel. A driver should use 
dev_kfree_skb instead, I guess.

Thanks,
/Waldek
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wei Yongjun March 21, 2013, 1:57 p.m. UTC | #2
On 03/21/2013 07:37 PM, Rymarkiewicz Waldemar wrote:
> Hi,
>
>> Use kfree_skb() instead of kfree() to free sk_buff.
>>
>> Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
>> ---
>>   drivers/nfc/microread/mei.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c
>> index eef38cf..da8264c 100644
>> --- a/drivers/nfc/microread/mei.c
>> +++ b/drivers/nfc/microread/mei.c
>> @@ -130,7 +130,7 @@ static void microread_event_cb(struct mei_device *device, u32 events,
>>
>>           reply_size = mei_recv(device, skb->data, MEI_NFC_MAX_READ);
>>           if (reply_size < MEI_NFC_HEADER_SIZE) {
>> -            kfree(skb);
>> +            kfree_skb(skb);
>>               return;
>>           }
>
> kfree_skb call is used internally by the kernel. A driver should use dev_kfree_skb instead, I guess.

It seems that dev_kfree_skb() call when dev_alloc_skb() is used, and
kfree_skb() use to free skb malloced by alloc_skb().

Regards,
Yongjun Wei 


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Waldemar Rymarkiewicz March 22, 2013, 10:38 a.m. UTC | #3
Hi,

>>
>> kfree_skb call is used internally by the kernel. A driver should use dev_kfree_skb instead, I guess.
>
> It seems that dev_kfree_skb() call when dev_alloc_skb() is used, and
> kfree_skb() use to free skb malloced by alloc_skb().

I agree. The driver should use  dev_* flavoured skb function then.


Thanks,
/Waldek


--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Samuel Ortiz March 28, 2013, 11:23 a.m. UTC | #4
Hi Waldemar,

On Fri, Mar 22, 2013 at 11:38:57AM +0100, Rymarkiewicz Waldemar wrote:
> Hi,
> 
> >>
> >>kfree_skb call is used internally by the kernel. A driver should use dev_kfree_skb instead, I guess.
> >
> >It seems that dev_kfree_skb() call when dev_alloc_skb() is used, and
> >kfree_skb() use to free skb malloced by alloc_skb().
> 
> I agree. The driver should use  dev_* flavoured skb function then.
I'd prefer the driver to call nfc_alloc_recv_skb() instead. This one calls
alloc_skb() but we could have it call dev_alloc_skb() I suppose. dev_alloc_skb
does atomic allocation though.
And kfree_skb() or dev_kfree_skb() is essentially the same.

I'll fix the driver so that it calls nfc_alloc_recv_skb() and kfree_skb unless
Wei beats me at it.

Cheers,
Samuel.
diff mbox

Patch

diff --git a/drivers/nfc/microread/mei.c b/drivers/nfc/microread/mei.c
index eef38cf..da8264c 100644
--- a/drivers/nfc/microread/mei.c
+++ b/drivers/nfc/microread/mei.c
@@ -130,7 +130,7 @@  static void microread_event_cb(struct mei_device *device, u32 events,
 
 		reply_size = mei_recv(device, skb->data, MEI_NFC_MAX_READ);
 		if (reply_size < MEI_NFC_HEADER_SIZE) {
-			kfree(skb);
+			kfree_skb(skb);
 			return;
 		}