crypto/ccp: fix resource leak

Message ID 20181028031928.46445-1-ferruh.yigit@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/ccp: fix resource leak |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Ferruh Yigit Oct. 28, 2018, 3:19 a.m. UTC
  File *fp, opened but not closed, this patch add fclose(fp)

Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
Cc: stable@dpdk.org

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/crypto/ccp/ccp_pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Kumar, Ravi1 Nov. 4, 2018, 4:50 a.m. UTC | #1
>File *fp, opened but not closed, this patch add fclose(fp)
>
>Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
>Cc: stable@dpdk.org
>
>Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>---
> drivers/crypto/ccp/ccp_pci.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/crypto/ccp/ccp_pci.c b/drivers/crypto/ccp/ccp_pci.c index 59152ca5d..1702a09c4 100644
>--- a/drivers/crypto/ccp/ccp_pci.c
>+++ b/drivers/crypto/ccp/ccp_pci.c
>@@ -31,12 +31,15 @@ ccp_check_pci_uio_module(void)
> 	while (uio_module_names[i] != NULL) {
> 		while (fgets(buf, sizeof(buf), fp) != NULL) {
> 			if (!strncmp(buf, uio_module_names[i],
>-				     strlen(uio_module_names[i])))
>+				     strlen(uio_module_names[i]))) {
>+				fclose(fp);
> 				return i;
>+			}
> 		}
> 		i++;
> 		rewind(fp);
> 	}
>+	fclose(fp);
> 	printf("Insert igb_uio or uio_pci_generic kernel module(s)");
> 	return -1;/* uio not inserted */
> }
>--
>2.17.2
>
Thanks Ferruh for the find. Looks good to me.

Regards,
Ravi
  
Akhil Goyal Nov. 12, 2018, 12:49 p.m. UTC | #2
On 11/4/2018 10:20 AM, Kumar, Ravi1 wrote:
>> File *fp, opened but not closed, this patch add fclose(fp)
>>
>> Fixes: ef4b04f87fa6 ("crypto/ccp: support device init")
>> Cc: stable@dpdk.org
>>
>> Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
>> ---
>> drivers/crypto/ccp/ccp_pci.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/crypto/ccp/ccp_pci.c b/drivers/crypto/ccp/ccp_pci.c index 59152ca5d..1702a09c4 100644
>> --- a/drivers/crypto/ccp/ccp_pci.c
>> +++ b/drivers/crypto/ccp/ccp_pci.c
>> @@ -31,12 +31,15 @@ ccp_check_pci_uio_module(void)
>> 	while (uio_module_names[i] != NULL) {
>> 		while (fgets(buf, sizeof(buf), fp) != NULL) {
>> 			if (!strncmp(buf, uio_module_names[i],
>> -				     strlen(uio_module_names[i])))
>> +				     strlen(uio_module_names[i]))) {
>> +				fclose(fp);
>> 				return i;
>> +			}
>> 		}
>> 		i++;
>> 		rewind(fp);
>> 	}
>> +	fclose(fp);
>> 	printf("Insert igb_uio or uio_pci_generic kernel module(s)");
>> 	return -1;/* uio not inserted */
>> }
>> --
>> 2.17.2
>>
> Thanks Ferruh for the find. Looks good to me.
>
> Regards,
> Ravi
Added Reviewed-by from Ravi.
Applied to dpdk-next-crypto

Thanks
  

Patch

diff --git a/drivers/crypto/ccp/ccp_pci.c b/drivers/crypto/ccp/ccp_pci.c
index 59152ca5d..1702a09c4 100644
--- a/drivers/crypto/ccp/ccp_pci.c
+++ b/drivers/crypto/ccp/ccp_pci.c
@@ -31,12 +31,15 @@  ccp_check_pci_uio_module(void)
 	while (uio_module_names[i] != NULL) {
 		while (fgets(buf, sizeof(buf), fp) != NULL) {
 			if (!strncmp(buf, uio_module_names[i],
-				     strlen(uio_module_names[i])))
+				     strlen(uio_module_names[i]))) {
+				fclose(fp);
 				return i;
+			}
 		}
 		i++;
 		rewind(fp);
 	}
+	fclose(fp);
 	printf("Insert igb_uio or uio_pci_generic kernel module(s)");
 	return -1;/* uio not inserted */
 }