bpf-lirc.c (93081caaaed6a40a4f6d9b7ba3f581a4bb1d4404) | bpf-lirc.c (92cab799bbc6fa1fca84bd1692285a5f926c17e9) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2// bpf-lirc.c - handles bpf 3// 4// Copyright (C) 2018 Sean Young <sean@mess.org> 5 6#include <linux/bpf.h> 7#include <linux/filter.h> 8#include <linux/bpf_lirc.h> --- 160 unchanged lines hidden (view full) --- 169 * with a dummy entry in the array, and the we would free the 170 * dummy in lirc_bpf_free() 171 */ 172 if (ret) 173 goto unlock; 174 175 rcu_assign_pointer(raw->progs, new_array); 176 bpf_prog_array_free(old_array); | 1// SPDX-License-Identifier: GPL-2.0 2// bpf-lirc.c - handles bpf 3// 4// Copyright (C) 2018 Sean Young <sean@mess.org> 5 6#include <linux/bpf.h> 7#include <linux/filter.h> 8#include <linux/bpf_lirc.h> --- 160 unchanged lines hidden (view full) --- 169 * with a dummy entry in the array, and the we would free the 170 * dummy in lirc_bpf_free() 171 */ 172 if (ret) 173 goto unlock; 174 175 rcu_assign_pointer(raw->progs, new_array); 176 bpf_prog_array_free(old_array); |
177 bpf_prog_put(prog); |
|
177unlock: 178 mutex_unlock(&ir_raw_handler_lock); 179 return ret; 180} 181 182void lirc_bpf_run(struct rc_dev *rcdev, u32 sample) 183{ 184 struct ir_raw_event_ctrl *raw = rcdev->raw; --- 17 unchanged lines hidden (view full) --- 202 203 progs = rcu_dereference(rcdev->raw->progs)->progs; 204 while (*progs) 205 bpf_prog_put(*progs++); 206 207 bpf_prog_array_free(rcdev->raw->progs); 208} 209 | 178unlock: 179 mutex_unlock(&ir_raw_handler_lock); 180 return ret; 181} 182 183void lirc_bpf_run(struct rc_dev *rcdev, u32 sample) 184{ 185 struct ir_raw_event_ctrl *raw = rcdev->raw; --- 17 unchanged lines hidden (view full) --- 203 204 progs = rcu_dereference(rcdev->raw->progs)->progs; 205 while (*progs) 206 bpf_prog_put(*progs++); 207 208 bpf_prog_array_free(rcdev->raw->progs); 209} 210 |
210int lirc_prog_attach(const union bpf_attr *attr, struct bpf_prog *prog) | 211int lirc_prog_attach(const union bpf_attr *attr) |
211{ | 212{ |
213 struct bpf_prog *prog; |
|
212 struct rc_dev *rcdev; 213 int ret; 214 215 if (attr->attach_flags) 216 return -EINVAL; 217 | 214 struct rc_dev *rcdev; 215 int ret; 216 217 if (attr->attach_flags) 218 return -EINVAL; 219 |
220 prog = bpf_prog_get_type(attr->attach_bpf_fd, 221 BPF_PROG_TYPE_LIRC_MODE2); 222 if (IS_ERR(prog)) 223 return PTR_ERR(prog); 224 |
|
218 rcdev = rc_dev_get_from_fd(attr->target_fd); | 225 rcdev = rc_dev_get_from_fd(attr->target_fd); |
219 if (IS_ERR(rcdev)) | 226 if (IS_ERR(rcdev)) { 227 bpf_prog_put(prog); |
220 return PTR_ERR(rcdev); | 228 return PTR_ERR(rcdev); |
229 } |
|
221 222 ret = lirc_bpf_attach(rcdev, prog); | 230 231 ret = lirc_bpf_attach(rcdev, prog); |
232 if (ret) 233 bpf_prog_put(prog); |
|
223 224 put_device(&rcdev->dev); 225 226 return ret; 227} 228 229int lirc_prog_detach(const union bpf_attr *attr) 230{ --- 73 unchanged lines hidden --- | 234 235 put_device(&rcdev->dev); 236 237 return ret; 238} 239 240int lirc_prog_detach(const union bpf_attr *attr) 241{ --- 73 unchanged lines hidden --- |