Skip to content

Commit

Permalink
Fix integer overflow coverity issues in CPU plugin: 1548297, 1548502,…
Browse files Browse the repository at this point in the history
… 1548522 (#28261)

### Details:
- This PR fixes coverity issue with CID 1548297, 1548502, 1548522
(overflowed constant)

### Tickets:
 - [CVS-145092](https://jira.devtools.intel.com/browse/CVS-145092)
  • Loading branch information
aobolensk authored Jan 3, 2025
1 parent 2bdaf5a commit dc8c4ee
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/plugins/intel_cpu/src/nodes/adaptive_pooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void AdaptivePooling::execute(dnnl::stream strm) {
auto dstStrides = getChildEdgeAt(0)->getMemory().getDescWithType<BlockedMemoryDesc>()->getStrides();

// unified strides array
const size_t tailDimsOffset = (isTailCFmt ? -1 : 0);
const ptrdiff_t tailDimsOffset = (isTailCFmt ? -1 : 0);
const size_t inStrides[5] = {srcStrides[0],
(isTailCFmt ? 1 : srcStrides[1]),
(spatialDimsCount == 3 ? srcStrides[2 + tailDimsOffset] : 0),
Expand Down
1 change: 1 addition & 0 deletions src/plugins/intel_cpu/src/nodes/batch_to_space.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ void BatchToSpace::batchToSpaceKernel() {
size_t channels = (inShape5D[1] / blockSize);
channels = channels == 0 ? 1 : channels;
const size_t workAmount = inShape5D[0] * channels;
OPENVINO_ASSERT(workAmount > 0, errorPrefix, " has unsupported work amount == 0");

parallel_nt(0, [&](const int ithr, const int nthr) {
size_t start(0lu), end(0lu);
Expand Down
8 changes: 5 additions & 3 deletions src/plugins/intel_cpu/src/nodes/subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ struct SubgraphCodeGeneratorKey {
bool operator==(const SubgraphCodeGeneratorKey& rhs) const;

std::shared_ptr<Subgraph::SubgraphAttrs> attrs = nullptr;
uint8_t broadcasting_mask = 0;
uint32_t broadcasting_mask = 0;
};

struct SubgraphShapeInferResultKey {
Expand Down Expand Up @@ -738,8 +738,10 @@ Subgraph::ControlFlowPasses Subgraph::getControlFlowPasses() const {
return backend_passes;
}

uint8_t Subgraph::getBroadcastingMask(const std::vector<VectorDims>& input_shapes) {
uint8_t mask = 0;
uint32_t Subgraph::getBroadcastingMask(const std::vector<VectorDims>& input_shapes) {
uint32_t mask = 0;
OPENVINO_ASSERT(broadcastable_inputs.size() <= sizeof(mask) * CHAR_BIT,
"Incorrect size of broadcastable inputs of Subgraph");
for (const auto& broadcastable_input : broadcastable_inputs) {
const auto& shape = input_shapes[broadcastable_input.first];
mask = mask << 1;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/intel_cpu/src/nodes/subgraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Subgraph : public Node {
std::pair<std::vector<ov::element::Type>, std::vector<ov::element::Type>> getIOPrecisions() const;

static uint64_t getBodyHash(const std::shared_ptr<snippets::op::Subgraph>& snippet);
uint8_t getBroadcastingMask(const std::vector<VectorDims>& input_shapes);
uint32_t getBroadcastingMask(const std::vector<VectorDims>& input_shapes);

using DataFlowPasses = std::vector<ov::snippets::pass::Manager::PositionedPassBase>;
using ControlFlowPasses = std::vector<ov::snippets::lowered::pass::PassPipeline::PositionedPassLowered>;
Expand Down

0 comments on commit dc8c4ee

Please sign in to comment.