Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1568035 > unrolled thread

[PATCH] Input: tegra-kbc - Fix possible NULL derefrence.

Started byShailendra Verma <shailendra.v@samsung.com>
First post2017-01-27 11:50 +0100
Last post2017-01-27 12:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH] Input: tegra-kbc - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-27 11:50 +0100
    Re: [PATCH] Input: tegra-kbc - Fix possible NULL derefrence. Thierry Reding <thierry.reding@gmail.com> - 2017-01-27 12:10 +0100

#1568035 — [PATCH] Input: tegra-kbc - Fix possible NULL derefrence.

FromShailendra Verma <shailendra.v@samsung.com>
Date2017-01-27 11:50 +0100
Subject[PATCH] Input: tegra-kbc - Fix possible NULL derefrence.
Message-ID<t4cgq-2YU-7@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1568079

FromThierry Reding <thierry.reding@gmail.com>
Date2017-01-27 12:10 +0100
Message-ID<t4czN-3lb-35@gated-at.bofh.it>
In reply to#1568035

[Multipart message — attachments visible in raw view] — view raw

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web