From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753346AbcJKSMT (ORCPT ); Tue, 11 Oct 2016 14:12:19 -0400 Received: from mga14.intel.com ([192.55.52.115]:21327 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751917AbcJKSMS (ORCPT ); Tue, 11 Oct 2016 14:12:18 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,330,1473145200"; d="scan'208";a="1063445996" Date: Tue, 11 Oct 2016 21:12:11 +0300 From: Jarkko Sakkinen To: Nayna Cc: Jason Gunthorpe , Peter Huewe , Marcel Selhorst , "moderated list:TPM DEVICE DRIVER" , open list Subject: Re: [PATCH RESEND 2/3] tpm: replace dynamically allocated bios_dir with a static array Message-ID: <20161011181211.GB6900@intel.com> References: <1475349926-476-1-git-send-email-jarkko.sakkinen@linux.intel.com> <1475349926-476-3-git-send-email-jarkko.sakkinen@linux.intel.com> <57FBE39B.2030301@linux.vnet.ibm.com> <20161011112315.GB21688@intel.com> <20161011165355.GB6881@obsidianresearch.com> <57FD1F3C.6070705@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <57FD1F3C.6070705@linux.vnet.ibm.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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