Skip to content

Commit 07f305c

Browse files
committed
[NDIS] NdisOpenFile: use local variables instead of using output variables
1 parent 71b6fab commit 07f305c

File tree

1 file changed

+16
-13
lines changed
  • drivers/network/ndis/ndis

1 file changed

+16
-13
lines changed

drivers/network/ndis/ndis/misc.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -228,10 +228,12 @@ NdisOpenFile(
228228
IN PNDIS_STRING FileName,
229229
IN NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress)
230230
{
231+
HANDLE NtFileHandle = NULL;
231232
NDIS_STRING FullFileName;
232233
OBJECT_ATTRIBUTES ObjectAttributes;
233234
PNDIS_HANDLE_OBJECT FileHandleObject = NULL;
234235
IO_STATUS_BLOCK IoStatusBlock;
236+
NTSTATUS NtStatus;
235237

236238
ASSERT_IRQL(PASSIVE_LEVEL);
237239

@@ -263,10 +265,10 @@ NdisOpenFile(
263265
memset ( FileHandleObject, 0, sizeof(NDIS_HANDLE_OBJECT) );
264266

265267
memmove ( FullFileName.Buffer, NDIS_FILE_FOLDER, FullFileName.Length );
266-
*Status = RtlAppendUnicodeStringToString ( &FullFileName, FileName );
267-
if ( !NT_SUCCESS(*Status) )
268+
NtStatus = RtlAppendUnicodeStringToString ( &FullFileName, FileName );
269+
if ( !NT_SUCCESS(NtStatus) )
268270
{
269-
NDIS_DbgPrint(MIN_TRACE, ("RtlAppendUnicodeStringToString failed (%x)\n", *Status));
271+
NDIS_DbgPrint(MIN_TRACE, ("RtlAppendUnicodeStringToString failed (%x)\n", NtStatus));
270272
*Status = NDIS_STATUS_FAILURE;
271273
goto cleanup;
272274
}
@@ -277,8 +279,8 @@ NdisOpenFile(
277279
NULL,
278280
NULL );
279281

280-
*Status = ZwCreateFile (
281-
&FileHandleObject->FileHandle,
282+
NtStatus = ZwCreateFile (
283+
&NtFileHandle,
282284
FILE_READ_DATA|SYNCHRONIZE,
283285
&ObjectAttributes,
284286
&IoStatusBlock,
@@ -290,10 +292,10 @@ NdisOpenFile(
290292
0, // PVOID EaBuffer
291293
0 ); // ULONG EaLength
292294

293-
if ( !NT_SUCCESS(*Status) )
295+
if ( !NT_SUCCESS(NtStatus) )
294296
{
295-
NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x) Name %wZ\n", *Status, FileName));
296-
*Status = NDIS_STATUS_FAILURE;
297+
NDIS_DbgPrint(MIN_TRACE, ("ZwCreateFile failed (%x) Name %wZ\n", NtStatus, FileName));
298+
*Status = NDIS_STATUS_FILE_NOT_FOUND;
297299
}
298300

299301
cleanup:
@@ -304,16 +306,17 @@ NdisOpenFile(
304306
}
305307
if ( !NT_SUCCESS(*Status) )
306308
{
307-
if( FileHandleObject ) {
308-
ExFreePool ( FileHandleObject );
309-
FileHandleObject = NULL;
309+
if ( FileHandleObject )
310+
{
311+
ExFreePool ( FileHandleObject );
310312
}
311313
*FileHandle = NULL;
312314
}
313315
else
316+
{
317+
FileHandleObject->FileHandle = NtFileHandle;
314318
*FileHandle = NDIS_POBJECT_TO_HANDLE(FileHandleObject);
315-
316-
return;
319+
}
317320
}
318321

319322
/*

0 commit comments

Comments
 (0)