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


Groups > linux.kernel > #1499124

Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir with a static array

From Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir with a static array
Date 2016-10-11 20:20 +0200
Message-ID <sr9OF-1Fj-11@gated-at.bofh.it> (permalink)
References (1 earlier) <sny8V-4tY-1@gated-at.bofh.it> <sqNXP-4MD-7@gated-at.bofh.it> <sr3pU-666-19@gated-at.bofh.it> <sr92h-15w-3@gated-at.bofh.it> <sr92h-15w-1@gated-at.bofh.it>
Organization Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo

Show all headers | View raw


On Tue, Oct 11, 2016 at 10:49:56PM +0530, Nayna wrote:
> 
> 
> On 10/11/2016 10:23 PM, Jason Gunthorpe wrote:
> >On Tue, Oct 11, 2016 at 02:23:15PM +0300, Jarkko Sakkinen wrote:
> >>>>+	chip->bios_dir[cnt] =
> >>>>  	    securityfs_create_file("ascii_bios_measurements",
> >>>>-				   S_IRUSR | S_IRGRP, tpm_dir,
> >>>>+				   S_IRUSR | S_IRGRP, chip->bios_dir[0],
> >>>>  				   (void *)&tpm_ascii_b_measurments_seqops,
> >>>>  				   &tpm_bios_measurements_ops);
> >
> >>>>+	if (is_bad(chip->bios_dir[cnt]))
> >>>>+		goto err;
> >
> >>>>+err:
> >>>>+	chip->bios_dir[cnt] = NULL;
> >>>
> >>>The updated patch looks fine.
> >>>Just, I am not sure if NULL assignment is needed.
> >>
> >>It's not needed.
> >
> >It is required to switch an ERR_PTR to NULL, see is_bad()
> 
> My understanding is that securityfs_remove() takes care of both NULL and
> ERR_PTR().
> 
> From securityfs_remove():
> 
>  if (!dentry || IS_ERR(dentry))
>                 return;

Right. I just checked from LXR. Seems weird that they have that kind of
special handling for IS_ERR. Checking for NULL is more usual.  I think I
keep setting NULL anyway if nothing else for robustness.  Anyway, thanks
for pointing this out.

> Thanks & Regards,
>   - Nayna

/Jarkko

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH RESEND 0/3] Clean up handling of event log files Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-01 21:30 +0200
  [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-01 21:30 +0200
    Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-10-02 23:30 +0200
      Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-03 14:30 +0200
        Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-08 13:10 +0200
    Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Nayna <nayna@linux.vnet.ibm.com> - 2016-10-10 21:00 +0200
      Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-11 13:30 +0200
        Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Nayna <nayna@linux.vnet.ibm.com> - 2016-10-11 19:30 +0200
          Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-11 20:20 +0200
        Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2016-10-11 19:40 +0200
          Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir  with a static array Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-11 20:20 +0200
  [PATCH RESEND 3/3] tpm: drop tpm1_chip_register(/unregister) Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-01 21:30 +0200
  [PATCH RESEND 1/3] tpm: define a generic open() method for ascii & bios measurements Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-01 21:30 +0200
    Re: [PATCH RESEND 1/3] tpm: define a generic open() method for ascii  & bios measurements Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2016-10-08 13:10 +0200

csiph-web