Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion drivers/cxl/core/hdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/seq_file.h>
#include <linux/device.h>
#include <linux/delay.h>
#include <linux/err.h>

#include "cxlmem.h"
#include "core.h"
Expand Down Expand Up @@ -617,6 +618,9 @@ cxl_find_free_decoder(struct cxl_memdev *cxlmd)
struct cxl_port *endpoint = cxlmd->endpoint;
struct device *dev;

if (IS_ERR_OR_NULL(endpoint))
return NULL;

guard(rwsem_read)(&cxl_rwsem.dpa);
dev = device_find_child(&endpoint->dev, NULL, find_free_decoder);
if (!dev)
Expand Down Expand Up @@ -759,7 +763,7 @@ struct cxl_endpoint_decoder *cxl_get_committed_decoder(struct cxl_memdev *cxlmd,
struct cxl_endpoint_decoder *cxled;
struct device *cxled_dev;

if (!endpoint)
if (IS_ERR_OR_NULL(endpoint))
return NULL;

guard(rwsem_read)(&cxl_rwsem.dpa);
Expand Down
6 changes: 4 additions & 2 deletions drivers/cxl/core/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <linux/genalloc.h>
#include <linux/debugfs.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/module.h>
#include <linux/memory.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -814,7 +815,7 @@ struct cxl_root_decoder *cxl_get_hpa_freespace(struct cxl_memdev *cxlmd,
struct cxl_port *endpoint;

endpoint = cxlmd->endpoint;
if (!endpoint) {
if (IS_ERR_OR_NULL(endpoint)) {
dev_dbg(&cxlmd->dev, "endpoint not linked to memdev\n");
return ERR_PTR(-ENXIO);
}
Expand Down Expand Up @@ -3172,7 +3173,8 @@ struct cxl_region *cxl_dpa_to_region(const struct cxl_memdev *cxlmd, u64 dpa)
.dpa = dpa,
};
port = cxlmd->endpoint;
if (port && is_cxl_endpoint(port) && cxl_num_decoders_committed(port))
if (!IS_ERR_OR_NULL(port) && is_cxl_endpoint(port) &&
cxl_num_decoders_committed(port))
device_for_each_child(&port->dev, &ctx, __cxl_dpa_to_region);

return ctx.cxlr;
Expand Down
Loading