Re: [PATCH] mm: cma: Fix potential null dereference on pointer cma

From: Minchan Kim
Date: Tue Mar 16 2021 - 14:11:56 EST


On Tue, Mar 16, 2021 at 10:04:33AM +0000, Colin King wrote:
> From: Colin Ian King <colin.king@xxxxxxxxxxxxx>
>
> At the start of the function there is a null pointer check on cma
> and then branch to error handling label 'out'. The subsequent call
> to cma_sysfs_fail_pages_count dereferences cma, hence there is a
> potential null pointer deference issue. Fix this by only calling
> cma_sysfs_fail_pages_count if cma is not null.
>
> Addresses-Coverity: ("Dereference after null check")
> Fixes: dc4764f7e9ac ("mm: cma: support sysfs")
> Signed-off-by: Colin Ian King <colin.king@xxxxxxxxxxxxx>
Acked-by: Minchan Kim <minchan@xxxxxxxxxx>