Thread (6 messages) flat view 6 messages, 2 authors, 2016-08-25

Re: [PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM

From: Alban Bedel <hidden>
Date: 2016-08-25 10:08:44
Also in: lkml

On Thu, 25 Aug 2016 11:16:36 +0200
Oliver Neukum [off-list ref] wrote:
On Wed, 2016-08-24 at 16:40 +0200, Alban Bedel wrote:
quoted
On Wed, 24 Aug 2016 16:30:39 +0200
Oliver Neukum [off-list ref] wrote:
  
quoted
On Wed, 2016-08-24 at 15:52 +0200, Alban Bedel wrote:  
quoted
quoted
quoted
+       if (block != data)
+               kfree(block);    
And if block == dta, what frees the memory?  
In this case this function didn't allocate any memory, so there is
nothing to free.  
Hi,

I see. kfree() has a check for NULL, so you could drop the
test, but it doesn't matter much either way.
I think you misunderstand something here. data is the buffer passed
by the caller and block is a local variable. There is two cases:

1) The data to write is block aligned, then we use the caller buffer
   as is and set block = data.
2) The requested data is not block aligned, then we kalloc block.

In both case the writing loop then use the block pointer. Afterwards
we only need to kfree block in case 2, that is when block != data.

Alban

Attachments

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help