Let R be a prime ring of characteristic different from 2 with its Utumi ring of quotients U, extended centroid C, $$f(x_1,\ldots ,x_n)$$ a multilinear polynomial over C, which is not central-valued on R and d a nonzero derivation of R. By f(R), we mean the set of all evaluations of the polynomial $$f(x_1,\ldots ,x_n)$$ in R. In the present paper, we study $$b[d(u),u]+p[d(u),u]q+[d(u),u]c=0$$ for all $$u\in f(R)$$ , which includes left-sided, right-sided as well as two-sided annihilating conditions of the set $$\{[d(u),u] : u\in f(R)\}$$ . We also examine some consequences of this result related to generalized derivations and we prove that if F is a generalized derivation of R and d is a nonzero derivation of R such that $$\begin{aligned} F^2([d(u), u])=0 \end{aligned}$$ for all $$u\in f(R)$$ , then there exists $$a\in U$$ with $$a^2=0$$ such that $$F(x)=xa$$ for all $$x\in R$$ or $$F(x)=ax$$ for all $$x\in R$$ .