diff mbox series

EDAC/synopsys: Fix wrong return value of mc_probe()

Message ID 20201116135810.3130845-1-zhangxiaoxu5@huawei.com (mailing list archive)
State New, archived
Headers show
Series EDAC/synopsys: Fix wrong return value of mc_probe() | expand

Commit Message

Zhang Xiaoxu Nov. 16, 2020, 1:58 p.m. UTC
If create the inject sysfs file failed, we should return
the error, rather than 0. Otherwise, there maybe error
pointer access.

Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
---
 drivers/edac/synopsys_edac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Michal Simek Nov. 18, 2020, 1:57 p.m. UTC | #1
On 16. 11. 20 14:58, Zhang Xiaoxu wrote:
> If create the inject sysfs file failed, we should return
> the error, rather than 0. Otherwise, there maybe error
> pointer access.
> 
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
> ---
>  drivers/edac/synopsys_edac.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c
> index 12211dc040e8..7e7146b22c16 100644
> --- a/drivers/edac/synopsys_edac.c
> +++ b/drivers/edac/synopsys_edac.c
> @@ -1344,7 +1344,8 @@ static int mc_probe(struct platform_device *pdev)
>  
>  #ifdef CONFIG_EDAC_DEBUG
>  	if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) {
> -		if (edac_create_sysfs_attributes(mci)) {
> +		rc = edac_create_sysfs_attributes(mci);
> +		if (rc) {
>  			edac_printk(KERN_ERR, EDAC_MC,
>  					"Failed to create sysfs entries\n");
>  			goto free_edac_mc;
> 

Reviewed-by: Michal Simek <michal.simek@xilinx.com>

Thanks,
Michal
Borislav Petkov Nov. 18, 2020, 6:36 p.m. UTC | #2
On Mon, Nov 16, 2020 at 08:58:10AM -0500, Zhang Xiaoxu wrote:
> If create the inject sysfs file failed, we should return
> the error, rather than 0. Otherwise, there maybe error
> pointer access.
> 
> Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
> ---
>  drivers/edac/synopsys_edac.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c
> index 12211dc040e8..7e7146b22c16 100644
> --- a/drivers/edac/synopsys_edac.c
> +++ b/drivers/edac/synopsys_edac.c
> @@ -1344,7 +1344,8 @@ static int mc_probe(struct platform_device *pdev)
>  
>  #ifdef CONFIG_EDAC_DEBUG
>  	if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) {
> -		if (edac_create_sysfs_attributes(mci)) {
> +		rc = edac_create_sysfs_attributes(mci);
> +		if (rc) {
>  			edac_printk(KERN_ERR, EDAC_MC,
>  					"Failed to create sysfs entries\n");
>  			goto free_edac_mc;
> -- 

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/edac/synopsys_edac.c b/drivers/edac/synopsys_edac.c
index 12211dc040e8..7e7146b22c16 100644
--- a/drivers/edac/synopsys_edac.c
+++ b/drivers/edac/synopsys_edac.c
@@ -1344,7 +1344,8 @@  static int mc_probe(struct platform_device *pdev)
 
 #ifdef CONFIG_EDAC_DEBUG
 	if (priv->p_data->quirks & DDR_ECC_DATA_POISON_SUPPORT) {
-		if (edac_create_sysfs_attributes(mci)) {
+		rc = edac_create_sysfs_attributes(mci);
+		if (rc) {
 			edac_printk(KERN_ERR, EDAC_MC,
 					"Failed to create sysfs entries\n");
 			goto free_edac_mc;