Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1568256 > unrolled thread
| Started by | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| First post | 2017-01-27 12:50 +0100 |
| Last post | 2017-01-27 13:50 +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.
[PATCH] Gpu: drm: rockchip - Fix possible NULL derefrence. Shailendra Verma <shailendra.v@samsung.com> - 2017-01-27 12:50 +0100
Re: [PATCH] Gpu: drm: rockchip - Fix possible NULL derefrence. Corentin Labbe <clabbe.montjoie@gmail.com> - 2017-01-27 13:50 +0100
| From | Shailendra Verma <shailendra.v@samsung.com> |
|---|---|
| Date | 2017-01-27 12:50 +0100 |
| Subject | [PATCH] Gpu: drm: rockchip - Fix possible NULL derefrence. |
| Message-ID | <t4dcv-3zE-63@gated-at.bofh.it> |
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.
Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
index ca22e5e..dbb99cf 100644
--- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
+++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
@@ -1082,15 +1082,22 @@ static enum drm_mode_status rk3288_mipi_dsi_mode_valid(
static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
void *data)
{
- const struct of_device_id *of_id =
- of_match_device(dw_mipi_dsi_dt_ids, dev);
- const struct dw_mipi_dsi_plat_data *pdata = of_id->data;
+ const struct of_device_id *of_id;
+ const struct dw_mipi_dsi_plat_data *pdata;
struct platform_device *pdev = to_platform_device(dev);
struct drm_device *drm = data;
struct dw_mipi_dsi *dsi;
struct resource *res;
int ret;
+ of_id = of_match_device(dw_mipi_dsi_dt_ids, dev);
+ if (!of_id) {
+ dev_err(dev, "Error: No device match found\n");
+ return -ENODEV;
+ }
+
+ pdata = of_id->data;
+
dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
if (!dsi)
return -ENOMEM;
--
1.7.9.5
[toc] | [next] | [standalone]
| From | Corentin Labbe <clabbe.montjoie@gmail.com> |
|---|---|
| Date | 2017-01-27 13:50 +0100 |
| Message-ID | <t4e8y-4cY-13@gated-at.bofh.it> |
| In reply to | #1568256 |
On Fri, Jan 27, 2017 at 04:41:50PM +0530, Shailendra Verma wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.
>
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
> drivers/gpu/drm/rockchip/dw-mipi-dsi.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> index ca22e5e..dbb99cf 100644
> --- a/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> +++ b/drivers/gpu/drm/rockchip/dw-mipi-dsi.c
> @@ -1082,15 +1082,22 @@ static enum drm_mode_status rk3288_mipi_dsi_mode_valid(
> static int dw_mipi_dsi_bind(struct device *dev, struct device *master,
> void *data)
> {
> - const struct of_device_id *of_id =
> - of_match_device(dw_mipi_dsi_dt_ids, dev);
> - const struct dw_mipi_dsi_plat_data *pdata = of_id->data;
> + const struct of_device_id *of_id;
> + const struct dw_mipi_dsi_plat_data *pdata;
> struct platform_device *pdev = to_platform_device(dev);
> struct drm_device *drm = data;
> struct dw_mipi_dsi *dsi;
> struct resource *res;
> int ret;
>
> + of_id = of_match_device(dw_mipi_dsi_dt_ids, dev);
> + if (!of_id) {
> + dev_err(dev, "Error: No device match found\n");
> + return -ENODEV;
> + }
> +
> + pdata = of_id->data;
> +
> dsi = devm_kzalloc(dev, sizeof(*dsi), GFP_KERNEL);
> if (!dsi)
> return -ENOMEM;
Hello
You could use of_device_get_match_data()
Regards
Corentin Labbe
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web