/* * Copyright (C) ST-Ericsson AB 2010 * Author: Sjur Brendeland * License terms: GNU General Public License (GPL) version 2 */ #define pr_fmt(fmt) KBUILD_MODNAME ":%s(): " fmt, __func__ #include #include #include #include #include #include #include #define container_obj(layr) ((struct cfsrvl *) layr) #define UTIL_PAYLOAD 0x00 #define UTIL_CMD_BIT 0x80 #define UTIL_REMOTE_SHUTDOWN 0x82 #define UTIL_FLOW_OFF 0x81 #define UTIL_FLOW_ON 0x80 static int cfutill_receive(struct cflayer *layr, struct cfpkt *pkt); static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info) { struct cfsrvl *util = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); if (!util) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); cfsrvl_init(util, channel_id, dev_info, true); util->layer.receive = cfutill_receive; util->layer.transmit = cfutill_transmit; snprintf(util->layer.name, CAIF_LAYER_NAME_SZ - 1, "util1"); return &util->layer; } static int cfutill_receive(struct cflayer *layr, struct cfpkt *pkt) { u8 cmd = -1; struct cfsrvl *service = container_obj(layr); caif_assert(layr != NULL); caif_assert(layr->up != NULL); caif_assert(layr->up->receive != NULL); caif_assert(layr->up->ctrlcmd != NULL); if (cfpkt_extr_head(pkt, &cmd, 1) < 0) { pr_err("Packet is erroneous!\n"); cfpkt_destroy(pkt); return -EPROTO; } switch (cmd) { case UTIL_PAYLOAD: return layr->up->receive(layr->up, pkt); case UTIL_FLOW_OFF: layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_OFF_IND, 0); cfpkt_destroy(pkt); return 0; case UTIL_FLOW_ON: layr->ctrlcmd(layr, CAIF_CTRLCMD_FLOW_ON_IND, 0); cfpkt_destroy(pkt); return 0; case UTIL_REMOTE_SHUTDOWN: /* Remote Shutdown Request */ pr_err("REMOTE SHUTDOWN REQUEST RECEIVED\n"); layr->ctrlcmd(layr, CAIF_CTRLCMD_REMOTE_SHUTDOWN_IND, 0); service->open = false; cfpkt_destroy(pkt); return 0; default: cfpkt_destroy(pkt); pr_warn("Unknown service control %d (0x%x)\n", cmd, cmd); return -EPROTO; } } static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt) { u8 zero = 0; struct caif_payload_info *info; int ret; struct cfsrvl *service = container_obj(layr); caif_assert(layr != NULL); caif_assert(layr->dn != NULL); caif_assert(layr->dn->transmit != NULL); if (!cfsrvl_ready(service, &ret)) { cfpkt_destroy(pkt); return ret; } cfpkt_add_head(pkt, &zero, 1); /* Add info for MUX-layer to route the packet out. */ info = cfpkt_info(pkt); info->channel_id = service->layer.id; /* * To optimize alignment, we add up the size of CAIF header before * payload. */ info->hdr_len = 1; info->dev_info = &service->dev_info; return layr->dn->transmit(layr->dn, pkt); } s-private-remove&id=5524ddd4c1f1624a7a96e6078a5ed81f493e7398'>root/tools/laptop/freefall
ame='context' onchange='this.form.submit();'>
AgeCommit message (Expand)AuthorFilesLines
space:
mode:
authorVincent <vincent.stehle@laposte.net>2017-01-30 15:06:43 +0100
committerDavid S. Miller <davem@davemloft.net>2017-01-31 13:07:40 -0500
commitc73e44269369e936165f0f9b61f1f09a11dae01c (patch)
treee2188e900ba06302f8ed2746cb07edd3efbc5c35 /net/netrom/nr_timer.c
parent040587af31228d82c52267f717c9fcdb65f36335 (diff)
net: thunderx: avoid dereferencing xcv when NULL
This fixes the following smatch and coccinelle warnings: drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119 xcv_setup_link() error: we previously assumed 'xcv' could be null (see line 118) [smatch] drivers/net/ethernet/cavium/thunder/thunder_xcv.c:119:16-20: ERROR: xcv is NULL but dereferenced. [coccinelle] Fixes: 6465859aba1e66a5 ("net: thunderx: Add RGMII interface type support") Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Cc: Sunil Goutham <sgoutham@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netrom/nr_timer.c')