All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] AMD_SFH: Fix potential NULL pointer dereference
@ 2021-06-01 16:38 Evgeny Novikov
  2021-09-15 14:58 ` Jiri Kosina
  2021-09-16  7:15 ` Jiri Kosina
  0 siblings, 2 replies; 5+ messages in thread
From: Evgeny Novikov @ 2021-06-01 16:38 UTC (permalink / raw)
  To: Nehal Shah
  Cc: Evgeny Novikov, Sandeep Singh, Jiri Kosina, Benjamin Tissoires,
	linux-input, linux-kernel, ldv-project

devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at
registration that will cause NULL pointer dereference since
corresponding data is not initialized yet. The patch moves
initialization of data before devm_add_action_or_reset().

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
---
 drivers/hid/amd-sfh-hid/amd_sfh_pcie.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
index ddecc84fd6f0..8394565c4d01 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
@@ -160,11 +160,16 @@ static int amd_mp2_pci_probe(struct pci_dev *pdev, const struct pci_device_id *i
 		rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
 		return rc;
 	}
+
+	rc = amd_sfh_hid_client_init(privdata);
+	if (rc)
+		return rc;
+
 	rc = devm_add_action_or_reset(&pdev->dev, amd_mp2_pci_remove, privdata);
 	if (rc)
 		return rc;
 
-	return amd_sfh_hid_client_init(privdata);
+	return 0;
 }
 
 static const struct pci_device_id amd_mp2_pci_tbl[] = {
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] AMD_SFH: Fix potential NULL pointer dereference
  2021-06-01 16:38 [PATCH] AMD_SFH: Fix potential NULL pointer dereference Evgeny Novikov
@ 2021-09-15 14:58 ` Jiri Kosina
  2021-09-15 17:32   ` Shah, Nehal-bakulchandra
  2021-09-16  7:15 ` Jiri Kosina
  1 sibling, 1 reply; 5+ messages in thread
From: Jiri Kosina @ 2021-09-15 14:58 UTC (permalink / raw)
  To: Evgeny Novikov
  Cc: Nehal Shah, Sandeep Singh, Benjamin Tissoires, linux-input,
	linux-kernel, ldv-project

On Tue, 1 Jun 2021, Evgeny Novikov wrote:

> devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at
> registration that will cause NULL pointer dereference since
> corresponding data is not initialized yet. The patch moves
> initialization of data before devm_add_action_or_reset().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

Nehal, Basavaraj, could you please Review/Ack this one?

Thanks,

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] AMD_SFH: Fix potential NULL pointer dereference
  2021-09-15 14:58 ` Jiri Kosina
@ 2021-09-15 17:32   ` Shah, Nehal-bakulchandra
  2021-09-16  5:59     ` Basavaraj Natikar
  0 siblings, 1 reply; 5+ messages in thread
From: Shah, Nehal-bakulchandra @ 2021-09-15 17:32 UTC (permalink / raw)
  To: Jiri Kosina, Evgeny Novikov
  Cc: Benjamin Tissoires, linux-input, linux-kernel, ldv-project,
	Natikar, Basavaraj

Adding Basavaraj

-----Original Message-----
From: Jiri Kosina <jikos@kernel.org> 
Sent: Wednesday, September 15, 2021 8:28 PM
To: Evgeny Novikov <novikov@ispras.ru>
Cc: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>; Sandeep Singh <sandeep.singh@amd.com>; Benjamin Tissoires <benjamin.tissoires@redhat.com>; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; ldv-project@linuxtesting.org
Subject: Re: [PATCH] AMD_SFH: Fix potential NULL pointer dereference

On Tue, 1 Jun 2021, Evgeny Novikov wrote:

> devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at 
> registration that will cause NULL pointer dereference since 
> corresponding data is not initialized yet. The patch moves 
> initialization of data before devm_add_action_or_reset().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

Nehal, Basavaraj, could you please Review/Ack this one?

Thanks,

--
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] AMD_SFH: Fix potential NULL pointer dereference
  2021-09-15 17:32   ` Shah, Nehal-bakulchandra
@ 2021-09-16  5:59     ` Basavaraj Natikar
  0 siblings, 0 replies; 5+ messages in thread
From: Basavaraj Natikar @ 2021-09-16  5:59 UTC (permalink / raw)
  To: Shah, Nehal-bakulchandra, Jiri Kosina, Evgeny Novikov
  Cc: Benjamin Tissoires, linux-input, linux-kernel, ldv-project,
	Natikar, Basavaraj

On 9/15/2021 11:02 PM, Shah, Nehal-bakulchandra wrote:
> Adding Basavaraj
>
> -----Original Message-----
> From: Jiri Kosina <jikos@kernel.org> 
> Sent: Wednesday, September 15, 2021 8:28 PM
> To: Evgeny Novikov <novikov@ispras.ru>
> Cc: Shah, Nehal-bakulchandra <Nehal-bakulchandra.Shah@amd.com>; Sandeep Singh <sandeep.singh@amd.com>; Benjamin Tissoires <benjamin.tissoires@redhat.com>; linux-input@vger.kernel.org; linux-kernel@vger.kernel.org; ldv-project@linuxtesting.org
> Subject: Re: [PATCH] AMD_SFH: Fix potential NULL pointer dereference
>
> On Tue, 1 Jun 2021, Evgeny Novikov wrote:
>
>> devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at 
>> registration that will cause NULL pointer dereference since 
>> corresponding data is not initialized yet. The patch moves 
>> initialization of data before devm_add_action_or_reset().
>>
>> Found by Linux Driver Verification project (linuxtesting.org).
>>
>> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>
> Nehal, Basavaraj, could you please Review/Ack this one?
>
Patch looks good to me. Acked-by: Basavaraj Natikar <Basavaraj.Natikar@amd.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] AMD_SFH: Fix potential NULL pointer dereference
  2021-06-01 16:38 [PATCH] AMD_SFH: Fix potential NULL pointer dereference Evgeny Novikov
  2021-09-15 14:58 ` Jiri Kosina
@ 2021-09-16  7:15 ` Jiri Kosina
  1 sibling, 0 replies; 5+ messages in thread
From: Jiri Kosina @ 2021-09-16  7:15 UTC (permalink / raw)
  To: Evgeny Novikov
  Cc: Nehal Shah, Sandeep Singh, Benjamin Tissoires, linux-input,
	linux-kernel, ldv-project

On Tue, 1 Jun 2021, Evgeny Novikov wrote:

> devm_add_action_or_reset() can suddenly invoke amd_mp2_pci_remove() at
> registration that will cause NULL pointer dereference since
> corresponding data is not initialized yet. The patch moves
> initialization of data before devm_add_action_or_reset().
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Evgeny Novikov <novikov@ispras.ru>

Applied, thank you.

-- 
Jiri Kosina
SUSE Labs


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-16  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-01 16:38 [PATCH] AMD_SFH: Fix potential NULL pointer dereference Evgeny Novikov
2021-09-15 14:58 ` Jiri Kosina
2021-09-15 17:32   ` Shah, Nehal-bakulchandra
2021-09-16  5:59     ` Basavaraj Natikar
2021-09-16  7:15 ` Jiri Kosina

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.