linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: tegra-kbc - Fix possible NULL derefrence.
       [not found] <CGME20170127104250epcas1p4cf918f7e98f557ae65136f027f7556f1@epcas1p4.samsung.com>
@ 2017-01-27 10:42 ` Shailendra Verma
  2017-01-27 10:54   ` Thierry Reding
  0 siblings, 1 reply; 2+ messages in thread
From: Shailendra Verma @ 2017-01-27 10:42 UTC (permalink / raw)
  To: Rakesh Iyer, Laxman Dewangan, Dmitry Torokhov, Stephen Warren,
	Thierry Reding, Alexandre Courbot, linux-input, linux-tegra,
	linux-kernel, p.shailesh, ashish.kalra, Shailendra Verma,
	Shailendra Verma
  Cc: vidushi.koul

of_match_device could return NULL, and so cause a NULL pointer
dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/input/keyboard/tegra-kbc.c |    5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/input/keyboard/tegra-kbc.c b/drivers/input/keyboard/tegra-kbc.c
index 0c07e10..1f213ba 100644
--- a/drivers/input/keyboard/tegra-kbc.c
+++ b/drivers/input/keyboard/tegra-kbc.c
@@ -617,6 +617,11 @@ static int tegra_kbc_probe(struct platform_device *pdev)
 	const struct of_device_id *match;
 
 	match = of_match_device(tegra_kbc_of_match, &pdev->dev);
+
+	if (!match) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
 
 	kbc = devm_kzalloc(&pdev->dev, sizeof(*kbc), GFP_KERNEL);
 	if (!kbc) {
-- 
1.7.9.5

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

* Re: [PATCH] Input: tegra-kbc - Fix possible NULL derefrence.
  2017-01-27 10:42 ` [PATCH] Input: tegra-kbc - Fix possible NULL derefrence Shailendra Verma
@ 2017-01-27 10:54   ` Thierry Reding
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2017-01-27 10:54 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Rakesh Iyer, Laxman Dewangan, Dmitry Torokhov, Stephen Warren,
	Alexandre Courbot, linux-input, linux-tegra, linux-kernel,
	p.shailesh, ashish.kalra, Shailendra Verma, vidushi.koul

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

On Fri, Jan 27, 2017 at 04:12:36PM +0530, Shailendra Verma wrote:
> of_match_device could return NULL, and so cause a NULL pointer
> dereference later.
> 
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
>  drivers/input/keyboard/tegra-kbc.c |    5 +++++
>  1 file changed, 5 insertions(+)

I think that's rather pointless. The driver is OF-only, so the only way
it will bind to a device is if the device's compatible matches one of
the entries in the tegra_kbc_of_match table, in which case match will
never be NULL.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2017-01-27 10:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20170127104250epcas1p4cf918f7e98f557ae65136f027f7556f1@epcas1p4.samsung.com>
2017-01-27 10:42 ` [PATCH] Input: tegra-kbc - Fix possible NULL derefrence Shailendra Verma
2017-01-27 10:54   ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).