net: ip: Fix dereference before NULL check
Fix warnings like "Dereference before NULL check". Also make check readable. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
d4c7f04a41
commit
d320100df4
1 changed files with 4 additions and 2 deletions
|
@ -1775,15 +1775,17 @@ int net_pkt_copy(struct net_pkt *pkt_dst,
|
||||||
|
|
||||||
static int32_t net_pkt_find_offset(struct net_pkt *pkt, uint8_t *ptr)
|
static int32_t net_pkt_find_offset(struct net_pkt *pkt, uint8_t *ptr)
|
||||||
{
|
{
|
||||||
struct net_buf *buf = pkt->buffer;
|
struct net_buf *buf;
|
||||||
uint32_t ret = -EINVAL;
|
uint32_t ret = -EINVAL;
|
||||||
uint16_t offset;
|
uint16_t offset;
|
||||||
|
|
||||||
if (!(ptr && pkt && buf)) {
|
if (!ptr || !pkt || !pkt->buffer) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = 0U;
|
offset = 0U;
|
||||||
|
buf = pkt->buffer;
|
||||||
|
|
||||||
while (buf) {
|
while (buf) {
|
||||||
if (buf->data <= ptr && ptr <= (buf->data + buf->len)) {
|
if (buf->data <= ptr && ptr <= (buf->data + buf->len)) {
|
||||||
ret = offset + (ptr - buf->data);
|
ret = offset + (ptr - buf->data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue