From: Oliver Neukum <oneukum@suse.com>
To: Alban Bedel <alban.bedel@avionic-design.de>
Cc: Freddy Xin <freddy@asix.com.tw>,
linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM
Date: Thu, 25 Aug 2016 12:08:28 +0200 [thread overview]
Message-ID: <1472119708.2877.24.camel@suse.com> (raw)
In-Reply-To: <20160825120733.3413d395@avionic-0020>
On Thu, 2016-08-25 at 12:07 +0200, Alban Bedel wrote:
> On Thu, 25 Aug 2016 11:16:36 +0200
> Oliver Neukum <oneukum@suse.com> wrote:
>
> > On Wed, 2016-08-24 at 16:40 +0200, Alban Bedel wrote:
> > > On Wed, 24 Aug 2016 16:30:39 +0200
> > > Oliver Neukum <oneukum@suse.com> wrote:
> > >
> > > > On Wed, 2016-08-24 at 15:52 +0200, Alban Bedel wrote:
> >
> > > > > + 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.
Thanks for the clarification. Maybe worth a comment in the code?
Regards
Oliver
prev parent reply other threads:[~2016-08-25 10:08 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-24 13:52 [PATCH] usbnet: ax88179_178a: Add support for writing the EEPROM Alban Bedel
2016-08-24 14:30 ` Oliver Neukum
2016-08-24 14:40 ` Alban Bedel
2016-08-25 9:16 ` Oliver Neukum
2016-08-25 10:07 ` Alban Bedel
2016-08-25 10:08 ` Oliver Neukum [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1472119708.2877.24.camel@suse.com \
--to=oneukum@suse.com \
--cc=alban.bedel@avionic-design.de \
--cc=freddy@asix.com.tw \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).