Skip to contentSkip to conversation

mfd: 88pm8xx: platform data bug fix

PATCH In review Chao Xie 3 participants 8 messages Aug 19, 2013 – Sep 2, 2013 Multifunction devices (MFD)

lore
Share & tools
lore

Chao Xie

author
#0 lore raw

cover mfd: 88pm8xx: platform data bug fix

The patches fix the bug that pdata may be NULL when driver uses it.

Chao Xie (2):
mfd: 88pm800: Fix the bug that pdata may be NULL
mfd: 88pm805: Fix the bug that pdata may be NULL

 drivers/mfd/88pm800.c |   10 ++++++----
 drivers/mfd/88pm805.c |    2 +-
 2 files changed, 7 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.4.1
author
#1 lore raw

PATCH 1/2 mfd: 88pm800: Fix the bug that pdata may be NULL

User pass platform data to device, and platform data may be NULL. Add the check for pdata.

---
 drivers/mfd/88pm800.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/mfd/88pm800.c +6 -4
index 6c95483..d4d272f 100644
@@ -333,9 +333,11 @@ static int device_rtc_init(struct pm80x_chip *chip,
 {
 	int ret;
 
-	rtc_devs[0].platform_data = pdata->rtc;
-	rtc_devs[0].pdata_size =
-			pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0;
+	if (pdata) {
+		rtc_devs[0].platform_data = pdata->rtc;
+		rtc_devs[0].pdata_size =
+				pdata->rtc ? sizeof(struct pm80x_rtc_pdata) : 0;
+	}
 	ret = mfd_add_devices(chip->dev, 0, &rtc_devs[0],
 			      ARRAY_SIZE(rtc_devs), NULL, 0, NULL);
 	if (ret) {
@@ -578,7 +580,7 @@ static int pm800_probe(struct i2c_client *client,
 		goto err_device_init;
 	}
 
-	if (pdata->plat_config)
+	if (pdata && pdata->plat_config)
 		pdata->plat_config(chip, pdata);
 
 	return 0;
Signature · 1 line
1.7.4.1
#2 lore raw

Re: [PATCH 1/2] mfd: 88pm800: Fix the bug that pdata may be NULL

Hi Xie,

Quoted 2 lines · Chao Xie

User pass platform data to device, and platform data may be NULL.

In which case do you get that ? With DT ?
Should rtc_init fail when pdata is NULL ?

You need to explain that, be it only for us to know if it's a critical fix or not.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#3 lore raw

Re: [PATCH 1/2] mfd: 88pm800: Fix the bug that pdata may be NULL

Quoted 11 lines · Samuel Ortiz

Hi Xie,

Quoted 2 lines · Chao Xie

User pass platform data to device, and platform data may be NULL.

In which case do you get that ? With DT ?
Should rtc_init fail when pdata is NULL ?

You need to explain that, be it only for us to know if it's a critical fix or not.

Sorry for late response.
If pdata is NULL, the driver will fail. So the error check should be done at the beginning of probe.
If (!pdata)
return -EINVAL;

Is that OK?

Quoted 6 lines

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

#4 lore raw

Re: [PATCH 1/2] mfd: 88pm800: Fix the bug that pdata may be NULL

Hi Xie,

Quoted 6 lines · Chao Xie
Quoted 5 lines · Samuel Ortiz

Hi Xie,

Quoted 2 lines · Chao Xie

User pass platform data to device, and platform data may be NULL.

Quoted 8 lines
Quoted 6 lines

In which case do you get that ? With DT ?
Should rtc_init fail when pdata is NULL ?

You need to explain that, be it only for us to know if it's a critical fix or not.

Sorry for late response.
If pdata is NULL, the driver will fail.

The question is: Why would pdata be NULL ? If there's a fundamental issue you're hiding with this patch, you probably want to fix the real problem instead.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#5 lore raw

Re: [PATCH 1/2] mfd: 88pm800: Fix the bug that pdata may be NULL

Quoted 12 lines · Samuel Ortiz

Hi Xie,

Quoted 9 lines · Chao Xie
Quoted 8 lines · Samuel Ortiz

Hi Xie,

Quoted 2 lines · Chao Xie

User pass platform data to device, and platform data may be NULL.

In which case do you get that ? With DT ?
Should rtc_init fail when pdata is NULL ?

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

You need to explain that, be it only for us to know if it's a critical fix or not.

Sorry for late response.
If pdata is NULL, the driver will fail.

The question is: Why would pdata be NULL ? If there's a fundamental issue you're hiding with this patch, you probably want to fix the real problem instead.

Maybe i do not explain it clearly.
The error is detected y some software checking tool.
Pdata is passed from dev->platform_data.
If the user pass the dev->platform_data to be NULL, at least mfd device driver need detect it, and reject it if it is not accpetable like return -EINVAL. Then the following probing code will not cause kernel panic if we access pdata->xxx.

Quoted 6 lines

Cheers,
Samuel.

--
Intel Open Source Technology Centre
http://oss.intel.com/

#6 lore raw

Re: [PATCH 1/2] mfd: 88pm800: Fix the bug that pdata may be NULL

Hi Chao,

Quoted 16 lines · Chao Xie
Quoted 15 lines · Samuel Ortiz

Hi Xie,

Quoted 12 lines · Chao Xie
Quoted 11 lines · Samuel Ortiz

Hi Xie,

Quoted 2 lines · Chao Xie

User pass platform data to device, and platform data may be NULL.

In which case do you get that ? With DT ?
Should rtc_init fail when pdata is NULL ?

You need to explain that, be it only for us to know if it's a critical fix or not.

Quoted 8 lines
Quoted 6 lines
Quoted 2 lines

Sorry for late response.
If pdata is NULL, the driver will fail.

The question is: Why would pdata be NULL ? If there's a fundamental issue you're hiding with this patch, you probably want to fix the real problem instead.

Maybe i do not explain it clearly.
The error is detected y some software checking tool.

Ok, that's clearer. So it's not an actual bug you saw in practice, I'll modify the changelog accordingly.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#7 lore raw

PATCH 2/2 mfd: 88pm805: Fix the bug that pdata may be NULL

In reply to Chao Xie

User pass platform data to device, and platform data may be NULL. Add the check for pdata.

---
 drivers/mfd/88pm805.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/88pm805.c +1 -1
index 5216022..57135bb 100644
@@ -243,7 +243,7 @@ static int pm805_probe(struct i2c_client *client,
 		goto err_805_init;
 	}
 
-	if (pdata->plat_config)
+	if (pdata && pdata->plat_config)
 		pdata->plat_config(chip, pdata);
 
 err_805_init:
Signature · 1 line
1.7.4.1